Re: [Python-Dev] Emacs users: hg-tools-grep

2012-12-12 Thread Brandon W Maister
Yes indeed-- in my eagerness to make my first post to python-dev be
well-received I completely forgot about git grep.

brandon


On Wed, Dec 12, 2012 at 9:20 AM, Xavier Morel python-...@masklinn.netwrote:

 On 2012-12-12, at 15:12 , Ross Lagerwall wrote:

  On Wed, Dec 12, 2012 at 01:27:21PM +0200, Petri Lehtinen wrote:
  Brandon W Maister wrote:
  (defconst git-tools-grep-command
   git ls-files -z | xargs -0 grep -In %s
   The command used for grepping files using git. See
 `git-tools-grep'.)
 
  What's wrong with git grep?
 
  Or hg grep, for that matter?

 hg grep searches the history, not the working copy. *-tools-grep only
 searches the working copy but automatically filters files to only search
 in files under version control.

 Which as far as I know is indeed what git-grep does already.
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe:
 http://mail.python.org/mailman/options/python-dev/quodlibetor%40gmail.com

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Draft PEP for time zone support.

2012-12-11 Thread Brandon W Maister
Barry you want github raw:
https://raw.github.com/regebro/tz-pep/master/pep-04tz.txt


On Tue, Dec 11, 2012 at 3:31 PM, Barry Warsaw ba...@python.org wrote:

 On Dec 11, 2012, at 04:23 PM, Lennart Regebro wrote:

 This PEP is also available on github:
 
 https://github.com/regebro/tz-pep/blob/master/pep-04tz.txt

 wget returns some html gobbledygook.  Why-oh-why github?!

 PEP: 4??

 I've assigned this PEP 431, reformatted a few extra wide paragraphs,
 committed
 and pushed.

 Thanks Lennart!
 -Barry

 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe:
 http://mail.python.org/mailman/options/python-dev/quodlibetor%40gmail.com


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Emacs users: hg-tools-grep

2012-12-10 Thread Brandon W Maister

 P.S. Who wants to abuse Jono and Matthew's copyright again and provide a
 shudder git version?


Oh, I do!

I also feel weird about adding a copyright to this, but how will other
people feel comfortable using it if I don't?

Also I put it in github, in case people want to fix it:
https://github.com/quodlibetor/git-tools.el

;; Copyright (c) 2012 Brandon W Maister
;;
;; Permission is hereby granted, free of charge, to any person obtaining
;; a copy of this software and associated documentation files (the
;; Software), to deal in the Software without restriction, including
;; without limitation the rights to use, copy, modify, merge, publish,
;; distribute, sublicense, and/or sell copies of the Software, and to
;; permit persons to whom the Software is furnished to do so, subject to
;; the following conditions:
;;
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

;; This code is based on hg-tools.el, which in turn is based on bzr-tools.el
;; Copyright (c) 2008-2012 Jonathan Lange, Matthew Lefkowitz, Barry A.
Warsaw

(provide 'git-tools)

(defconst git-tools-grep-command
  git ls-files -z | xargs -0 grep -In %s
  The command used for grepping files using git. See `git-tools-grep'.)

;; Run 'code' at the root of the branch which dirname is in.
(defmacro git-tools-at-branch-root (dirname rest code)
  `(let ((default-directory (locate-dominating-file (expand-file-name
,dirname) .git))) ,@code))


(defun git-tools-grep (expression dirname)
  Search a branch for `expression'. If there's a C-u prefix, prompt for
`dirname'.
  (interactive
   (let* ((string (read-string Search for: ))
  (dir (if (null current-prefix-arg)
   default-directory
 (read-directory-name (format Search for %s in: 
string)
 (list string dir)))
  (git-tools-at-branch-root dirname
   (grep-find (format git-tools-grep-command (shell-quote-argument
expression)



On Sat, Dec 8, 2012 at 4:51 PM, Barry Warsaw ba...@python.org wrote:

 Hark fellow Emacsers.  All you unenlightened heathens can stop reading now.

 A few years ago, my colleague Jono Lange wrote probably the best little
 chunk
 of Emacs lisp ever.  `M-x bzr-tools-grep` lets you easily search a Bazaar
 repository for a case-sensitive string, providing you with a nice *grep*
 buffer which you can scroll through.  When you find a code sample you want
 to
 look at, C-c C-c visits the file and plops you right at the matching line.
 You *only* grep through files under version control, so you get to ignore
 generated files, and compilation artifacts, etc.

 Of course, this doesn't help you for working on the Python code base,
 because
 Mercurial.  I finally whipped up this straight up rip of Jono's code to
 work
 with hg.  I'm actually embarrassed to put a copyright on this thing, and
 would
 happily just donate it to Jono, drop it in Python's Misc directory, or
 slip it
 like a lump of coal into the xmas stocking of whoever wants to maintain
 it
 for the next 20 years.

 But anyway, it's already proven enormously helpful to me, so here it is.

 Cheers,
 -Barry

 P.S. Who wants to abuse Jono and Matthew's copyright again and provide a
 shudder git version?

 ;; Copyright (c) 2012 Barry A. Warsaw
 ;;
 ;; Permission is hereby granted, free of charge, to any person obtaining
 ;; a copy of this software and associated documentation files (the
 ;; Software), to deal in the Software without restriction, including
 ;; without limitation the rights to use, copy, modify, merge, publish,
 ;; distribute, sublicense, and/or sell copies of the Software, and to
 ;; permit persons to whom the Software is furnished to do so, subject to
 ;; the following conditions:
 ;;
 ;; The above copyright notice and this permission notice shall be
 ;; included in all copies or substantial portions of the Software.
 ;;
 ;; THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 ;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 ;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 ;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 ;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 ;; This code is based on bzr-tools.el
 ;; Copyright (c) 2008-2009 Jonathan Lange, Matthew Lefkowitz

 (provide 'hg

Re: [Python-Dev] performance of {} versus dict()

2012-11-14 Thread Brandon W Maister

 To (mis-)quote Antoine:
 -- d1 = {1:2}
 -- d2 = {'3':4}
 -- dict(d1, **d2)
  {1: 2, '3': 4}

 Apparently it is valid syntax.  Just make sure you keys for the **
 operator are valid strings.  :)


or not:

 dict(**{'not a valid identifier': True, 1: True})
{1: True, 'not a valid identifier': True}

brandon
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com