Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1bec4fc2
Commit
1bec4fc2
authored
Nov 15, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
2f095d3b
c95db62a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
0 additions
and
766 deletions
+0
-766
Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand
...-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand
+0
-64
Misc/TextMate/Python-Dev.tmbundle/Commands/Build Docs.tmCommand
...extMate/Python-Dev.tmbundle/Commands/Build Docs.tmCommand
+0
-23
Misc/TextMate/Python-Dev.tmbundle/Commands/Build.tmCommand
Misc/TextMate/Python-Dev.tmbundle/Commands/Build.tmCommand
+0
-25
Misc/TextMate/Python-Dev.tmbundle/Commands/Go to Issue.tmCommand
...xtMate/Python-Dev.tmbundle/Commands/Go to Issue.tmCommand
+0
-20
Misc/TextMate/Python-Dev.tmbundle/Commands/Open Docs.tmCommand
...TextMate/Python-Dev.tmbundle/Commands/Open Docs.tmCommand
+0
-32
Misc/TextMate/Python-Dev.tmbundle/Commands/Open PEP.tmCommand
.../TextMate/Python-Dev.tmbundle/Commands/Open PEP.tmCommand
+0
-23
Misc/TextMate/Python-Dev.tmbundle/Snippets/2 to 3 - Module Deletion (docs).tmSnippet
...bundle/Snippets/2 to 3 - Module Deletion (docs).tmSnippet
+0
-16
Misc/TextMate/Python-Dev.tmbundle/info.plist
Misc/TextMate/Python-Dev.tmbundle/info.plist
+0
-37
Misc/Vim/python.vim
Misc/Vim/python.vim
+0
-148
Misc/Vim/syntax_test.py
Misc/Vim/syntax_test.py
+0
-62
Misc/Vim/vim_syntax.py
Misc/Vim/vim_syntax.py
+0
-229
Misc/Vim/vimrc
Misc/Vim/vimrc
+0
-87
No files found.
Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
#!/usr/bin/python
"""Generate code to warn about a module's removal in Python 3.0.
XXX Not supported:
- Module's in a package do not have their full name generated.
- Package's __init__ module; should detect and use the package's name instead.
"""
py_template = """from warnings import warnpy3k
warnpy3k("the ${1:%s} module has been removed in Python 3.0", stacklevel=2)
del warnpy3k$0"""
c_template = """
if (PyErr_WarnPy3k("the ${1:%s} module has been removed in "
"Python 3.0", 2)
<
0)
return;$0"""
import imp
import os
file_name = os.path.split(os.environ['TM_FILEPATH'])[1]
py_suffixes = reversed(sorted((suffix[0] for suffix in imp.get_suffixes() if suffix[2] == imp.PY_SOURCE), key=len))
c_suffixes = reversed(sorted((os.path.splitext(suffix[0])[0] + '.c'
for suffix in imp.get_suffixes() if suffix[2] == imp.C_EXTENSION), key=len))
pairings = ((py_suffixes, py_template), (c_suffixes, c_template))
def create_template(suffixes, template):
for suffix in suffixes:
if not file_name.endswith(suffix):
continue
module_name = file_name[:-len(suffix)]
return template % module_name
else:
return None
for template in (create_template(*pair) for pair in pairings):
if not template:
continue
print template,
break
else:
print 'XXX Could not generate code.'
</string>
<key>
input
</key>
<string>
none
</string>
<key>
name
</key>
<string>
2 to 3 - Module Deletion
</string>
<key>
output
</key>
<string>
insertAsSnippet
</string>
<key>
tabTrigger
</key>
<string>
2to3moddel
</string>
<key>
uuid
</key>
<string>
9519C22B-6AB8-41A1-94F6-079E0B45C147
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Commands/Build Docs.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
# XXX Leopard-specific unless have easy way to specific alternative Python executable.
cd $TM_PROJECT_DIRECTORY/Doc
make html 2
>&
1 | pre
rescan_project
</string>
<key>
input
</key>
<string>
none
</string>
<key>
name
</key>
<string>
Build Docs
</string>
<key>
output
</key>
<string>
showAsHTML
</string>
<key>
uuid
</key>
<string>
6EF151E5-7149-4F82-8796-0CC40FE589FA
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Commands/Build.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
# XXX TODO
# - Highlight any compiler warnings for Python code.
# - Point out if compile failed.
cd $TM_PROJECT_DIRECTORY
make -s -j2 2
>&
1 | pre
rescan_project
</string>
<key>
input
</key>
<string>
none
</string>
<key>
name
</key>
<string>
Build Python
</string>
<key>
output
</key>
<string>
showAsHTML
</string>
<key>
uuid
</key>
<string>
B545BB1B-A8E1-426C-B50A-426E78B96D38
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Commands/Go to Issue.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
open "http://bugs.python.org/issue$(cat)"
</string>
<key>
fallbackInput
</key>
<string>
word
</string>
<key>
input
</key>
<string>
selection
</string>
<key>
name
</key>
<string>
Go to Issue
</string>
<key>
output
</key>
<string>
discard
</string>
<key>
uuid
</key>
<string>
FD25A8DC-22DC-4ED4-B222-B943C8A9117D
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Commands/Open Docs.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
# Search order:
# - Current project.
# - TM_PYTHONDEV_DOCS.
# - Online docs in development.
html_index=$TM_PROJECT_DIRECTORY/Doc/build/html/index.html
if [[ -f $html_index ]]; then
open $html_index
elif [[ $TM_PYTHONDEV_DOCS ]]; then
open $TM_PYTHONDEV_DOCS
else
open http://docs.python.org/dev/
fi
</string>
<key>
input
</key>
<string>
none
</string>
<key>
keyEquivalent
</key>
<string>
@H
</string>
<key>
name
</key>
<string>
Open Docs
</string>
<key>
output
</key>
<string>
discard
</string>
<key>
uuid
</key>
<string>
BF336FFF-E14D-4BF1-A156-71CF768AC034
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Commands/Open PEP.tmCommand
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
beforeRunningCommand
</key>
<string>
nop
</string>
<key>
command
</key>
<string>
# XXX Worth supporting using a local copy?
# Dumb luck that an unrecognized number leads to a 0 being used.
open `printf "http://www.python.org/dev/peps/pep-%04d" $(cat)`
</string>
<key>
fallbackInput
</key>
<string>
word
</string>
<key>
input
</key>
<string>
selection
</string>
<key>
name
</key>
<string>
Open PEP
</string>
<key>
output
</key>
<string>
discard
</string>
<key>
uuid
</key>
<string>
EDBB037F-AAE3-4512-863F-D9AA82C9E51E
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/Snippets/2 to 3 - Module Deletion (docs).tmSnippet
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
content
</key>
<string>
.. deprecated:: 2.6
The :mod:\`${1}\` module has been deprecated for removal in Python 3.0.
${0}
</string>
<key>
name
</key>
<string>
2 to 3 - Module Deletion (docs)
</string>
<key>
tabTrigger
</key>
<string>
2to3docdel
</string>
<key>
uuid
</key>
<string>
0568410D-EAF1-4AF3-B6DE-8AF133A91821
</string>
</dict>
</plist>
Misc/TextMate/Python-Dev.tmbundle/info.plist
deleted
100644 → 0
View file @
2f095d3b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
mainMenu
</key>
<dict>
<key>
items
</key>
<array>
<string>
9519C22B-6AB8-41A1-94F6-079E0B45C147
</string>
<string>
0568410D-EAF1-4AF3-B6DE-8AF133A91821
</string>
<string>
------------------------------------
</string>
<string>
B545BB1B-A8E1-426C-B50A-426E78B96D38
</string>
<string>
6EF151E5-7149-4F82-8796-0CC40FE589FA
</string>
<string>
------------------------------------
</string>
<string>
BF336FFF-E14D-4BF1-A156-71CF768AC034
</string>
<string>
FD25A8DC-22DC-4ED4-B222-B943C8A9117D
</string>
<string>
EDBB037F-AAE3-4512-863F-D9AA82C9E51E
</string>
</array>
<key>
submenus
</key>
<dict/>
</dict>
<key>
name
</key>
<string>
Python-Dev
</string>
<key>
ordering
</key>
<array>
<string>
9519C22B-6AB8-41A1-94F6-079E0B45C147
</string>
<string>
0568410D-EAF1-4AF3-B6DE-8AF133A91821
</string>
<string>
B545BB1B-A8E1-426C-B50A-426E78B96D38
</string>
<string>
6EF151E5-7149-4F82-8796-0CC40FE589FA
</string>
<string>
FD25A8DC-22DC-4ED4-B222-B943C8A9117D
</string>
<string>
BF336FFF-E14D-4BF1-A156-71CF768AC034
</string>
<string>
EDBB037F-AAE3-4512-863F-D9AA82C9E51E
</string>
</array>
<key>
uuid
</key>
<string>
A932ECD1-D43A-4F57-B7FB-A1CEC3B65D20
</string>
</dict>
</plist>
Misc/Vim/python.vim
deleted
100644 → 0
View file @
2f095d3b
" Auto-generated Vim syntax file for Python (trunk: r60376M).
"
" To use: copy or symlink to ~/.vim/syntax/python.vim
if
exists
(
"b:current_syntax"
)
finish
endif
if
exists
(
"python_highlight_all"
)
let
python_highlight_numbers
=
1
let
python_highlight_builtins
=
1
let
python_highlight_exceptions
=
1
let
python_highlight_space_errors
=
1
endif
syn
keyword pythonStatement
as
assert
break
continue del except exec
finally
syn
keyword pythonStatement global lambda pass print raise
return
try
with
syn
keyword pythonStatement yield
syn
keyword pythonStatement def class nextgroup
=
pythonFunction skipwhite
syn
match
pythonFunction
"[a-zA-Z_][a-zA-Z0-9_]*"
contained
syn
keyword pythonRepeat
for
while
syn
keyword pythonConditional
if
elif
else
syn
keyword pythonOperator and
in
is
not or
syn
keyword pythonPreCondit import from
syn
match
pythonComment
"#.*$"
contains
=
pythonTodo
syn
keyword pythonTodo TODO FIXME XXX contained
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=
'+ end=+'
+
skip
=+
\\\\\
|
\\'
+
contains
=
pythonEscape
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=
"+ end=+"
+
skip
=+
\\\\\
|
\\"
+
contains
=
pythonEscape
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=
"""+ end=+"""
+
contains
=
pythonEscape
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=
'''+ end=+'''
+
contains
=
pythonEscape
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=[
rR
]
'+ end=+'
+
skip
=+
\\\\\
|
\\'
+
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=[
rR
]
"+ end=+"
+
skip
=+
\\\\\
|
\\"
+
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=[
rR
]
"""+ end=+"""
+
syn
region pythonString matchgroup
=
Normal
start
=+[
uU
]
\
=[
rR
]
'''+ end=+'''
+
syn
match
pythonEscape
+
\\
[
abfnrtv\'"\\
]+
contained
syn
match
pythonEscape
"\\\o\{1,3}"
contained
syn
match
pythonEscape
"\\x\x\{2}"
contained
syn
match
pythonEscape
"\(\\u\x\{4}\|\\U\x\{8}\)"
contained
syn
match
pythonEscape
"\\$"
if
exists
(
"python_highlight_numbers"
)
syn
match
pythonNumber
"\<0x\x\+[Ll]\=\>"
syn
match
pythonNumber
"\<\d\+[LljJ]\=\>"
syn
match
pythonNumber
"\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
syn
match
pythonNumber
"\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
syn
match
pythonNumber
"\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
endif
if
exists
(
"python_highlight_builtins"
)
syn
keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__
syn
keyword pythonBuiltin __import__ abs
all
any bool
syn
keyword pythonBuiltin buffer callable chr classmethod cmp
syn
keyword pythonBuiltin complex copyright credits delattr dict
syn
keyword pythonBuiltin
dir
divmod enumerate eval exec
exit
syn
keyword pythonBuiltin
filter
float frozenset getattr globals hasattr
syn
keyword pythonBuiltin hash help hex id int isinstance
syn
keyword pythonBuiltin issubclass iter len license list locals map
syn
keyword pythonBuiltin max min object oct open ord pow property quit
syn
keyword pythonBuiltin range reload repr reversed round
syn
keyword pythonBuiltin
set
setattr slice sorted staticmethod str sum
syn
keyword pythonBuiltin super trunc tuple type unicode vars
syn
keyword pythonBuiltin zip
endif
if
exists
(
"python_highlight_exceptions"
)
syn
keyword pythonException ArithmeticError AssertionError AttributeError
syn
keyword pythonException BaseException DeprecationWarning EOFError
syn
keyword pythonException EnvironmentError Exception FloatingPointError
syn
keyword pythonException FutureWarning GeneratorExit IOError ImportError
syn
keyword pythonException ImportWarning IndentationError IndexError
syn
keyword pythonException KeyError KeyboardInterrupt LookupError
syn
keyword pythonException MemoryError NameError NotImplementedError
syn
keyword pythonException OSError OverflowError PendingDeprecationWarning
syn
keyword pythonException ReferenceError RuntimeError RuntimeWarning
syn
keyword pythonException StopIteration SyntaxError
syn
keyword pythonException SyntaxWarning SystemError SystemExit TabError
syn
keyword pythonException TypeError UnboundLocalError UnicodeDecodeError
syn
keyword pythonException UnicodeEncodeError UnicodeError
syn
keyword pythonException UnicodeTranslateError UnicodeWarning
syn
keyword pythonException UserWarning ValueError Warning
syn
keyword pythonException ZeroDivisionError
endif
if
exists
(
"python_highlight_space_errors"
)
syn
match
pythonSpaceError display excludenl
"\S\s\+$"
ms
=
s
+
1
syn
match
pythonSpaceError display
" \+\t"
syn
match
pythonSpaceError display
"\t\+ "
endif
hi
def link pythonStatement Statement
hi
def link pythonStatement Statement
hi
def link pythonFunction Function
hi
def link pythonRepeat Repeat
hi
def link pythonConditional Conditional
hi
def link pythonOperator Operator
hi
def link pythonPreCondit PreCondit
hi
def link pythonComment Comment
hi
def link pythonTodo Todo
hi
def link pythonString String
hi
def link pythonEscape Special
hi
def link pythonEscape Special
if
exists
(
"python_highlight_numbers"
)
hi
def link pythonNumber Number
endif
if
exists
(
"python_highlight_builtins"
)
hi
def link pythonBuiltin Function
endif
if
exists
(
"python_highlight_exceptions"
)
hi
def link pythonException Exception
endif
if
exists
(
"python_highlight_space_errors"
)
hi
def link pythonSpaceError Error
endif
" Uncomment the 'minlines' statement line and comment out the 'maxlines'
" statement line; changes behaviour to look at least 2000 lines previously for
" syntax matches instead of at most 200 lines
syn
sync
match
pythonSync grouphere
NONE
"):$"
syn
sync
maxlines
=
200
"syn sync minlines=2000
let
b:current_syntax
=
"python"
Misc/Vim/syntax_test.py
deleted
100644 → 0
View file @
2f095d3b
"""Test file for syntax highlighting of editors.
Meant to cover a wide range of different types of statements and expressions.
Not necessarily sensical or comprehensive (assume that if one exception is
highlighted that all are, for instance).
Extraneous trailing whitespace can't be tested because of svn pre-commit hook
checks for such things.
"""
# Comment
# OPTIONAL: XXX catch your attention
# Statements
from
__future__
import
with_statement
# Import
from
sys
import
path
as
thing
assert
True
# keyword
def
foo
():
# function definition
return
[]
class
Bar
(
object
):
# Class definition
def
__enter__
(
self
):
pass
def
__exit__
(
self
,
*
args
):
pass
foo
()
# UNCOLOURED: function call
while
False
:
# 'while'
continue
for
x
in
foo
():
# 'for'
break
with
Bar
()
as
stuff
:
pass
if
False
:
pass
# 'if'
elif
False
:
pass
else
:
pass
# Constants
'single-quote'
,
u'unicode'
# Strings of all kinds; prefixes not highlighted
"double-quote"
"""triple double-quote"""
'''triple single-quote'''
r'raw'
ur'unicode raw'
'escape
\
n
'
'
\
04
'
# octal
'
\
xFF
'
# hex
'
\
u1111
'
# unicode character
1
# Integral
1L
1.0
# Float
.
1
1
+
2j
# Complex
# Expressions
1
and
2
or
3
# Boolean operators
2
<
3
# UNCOLOURED: comparison operators
spam
=
42
# UNCOLOURED: assignment
2
+
3
# UNCOLOURED: number operators
[]
# UNCOLOURED: list
{}
# UNCOLOURED: dict
(
1
,)
# UNCOLOURED: tuple
all
# Built-in functions
GeneratorExit
# Exceptions
Misc/Vim/vim_syntax.py
deleted
100644 → 0
View file @
2f095d3b
from
__future__
import
with_statement
# XXX(nnorwitz): what versions of python is this file supposed to work with?
# It uses the old print statement not in py3k.
import
keyword
import
exceptions
import
builtins
from
string
import
Template
from
sys
import
subversion
comment_header
=
'''" Auto-generated Vim syntax file for Python (%s: r%s).
"
" To use: copy or symlink to ~/.vim/syntax/python.vim'''
statement_header
=
"""
if exists("b:current_syntax")
finish
endif"""
statement_footer
=
'''
" Uncomment the 'minlines' statement line and comment out the 'maxlines'
" statement line; changes behaviour to look at least 2000 lines previously for
" syntax matches instead of at most 200 lines
syn sync match pythonSync grouphere NONE "):$"
syn sync maxlines=200
"syn sync minlines=2000
let b:current_syntax = "python"'''
looping
=
(
'for'
,
'while'
)
conditionals
=
(
'if'
,
'elif'
,
'else'
)
boolean_ops
=
(
'and'
,
'in'
,
'is'
,
'not'
,
'or'
)
import_stmts
=
(
'import'
,
'from'
)
object_defs
=
(
'def'
,
'class'
)
exception_names
=
sorted
(
exc
for
exc
in
dir
(
exceptions
)
if
not
exc
.
startswith
(
'__'
))
# Need to include functions that start with '__' (e.g., __import__), but
# nothing that comes with modules (e.g., __name__), so just exclude anything in
# the 'exceptions' module since we want to ignore exceptions *and* what any
# module would have
builtin_names
=
sorted
(
builtin
for
builtin
in
dir
(
builtins
)
if
builtin
not
in
dir
(
exceptions
))
escapes
=
(
r'+\\[abfnrtv\'"\\]+'
,
r'"\\\
o
\{1,3}"'
,
r'"\\x\
x
\{2}"'
,
r'"\
(
\\
u
\x\
{
4}\
|
\\
U
\x\
{8}
\)"'
,
r'"\\$"'
)
todos
=
(
"TODO"
,
"FIXME"
,
"XXX"
)
# XXX codify?
numbers
=
(
r'"\
<
0x\
x
\+[Ll]\
=
\>"'
,
r'"\
<
\d\
+[LljJ]
\=\
>
"'
,
'"
\
.
\
d
\
+
\
([eE][+-]
\
=
\
d
\
+
\
)
\
=[jJ]
\
=
\
>
"
'
,
'"
\
<
\
d
\
+
\
.
\
([eE][+-]
\
=
\
d
\
+
\
)
\
=[jJ]
\
=
\
>"'
,
'"
\
<
\
d
\
+
\
.
\
d
\
+
\
([eE][+-]
\
=
\
d
\
+
\
)
\
=[jJ]
\
=
\
>"'
)
contained
=
lambda
x
:
"%s contained"
%
x
def
str_regexes
():
"""Generator to yield various combinations of strings regexes"""
regex_template
=
Template
(
'matchgroup=Normal '
+
'start=+[uU]
\
=${
r
aw}${sep}+ '
+
'end=+${sep}+ '
+
'${skip} '
+
'${contains}'
)
skip_regex
=
Template
(
r'skip=+\\\\\
|
\\
${sep}+
')
for raw in ('', '
[
rR
]
'):
for separator in ("'", '"', '"""', "'''"):
if len(separator) == 1:
skip = skip_regex.substitute(sep=separator)
else:
skip = ''
contains = 'contains=pythonEscape' if not raw else ''
yield regex_template.substitute(raw=raw, sep=separator, skip=skip,
contains = contains)
space_errors = (r'excludenl "
\
S
\
s
\
+$
"
ms=s+1', r'"
\
+
\
t"', r'"
\
t
\
+
"
')
statements = (
('',
# XXX Might need to change pythonStatement since have
# specific Repeat, Conditional, Operator, etc. for 'while',
# etc.
[("Statement", "pythonStatement", "keyword",
(kw for kw in keyword.kwlist
if kw not in (looping + conditionals + boolean_ops +
import_stmts + object_defs))
),
("Statement", "pythonStatement", "keyword",
(' '.join(object_defs) +
' nextgroup=pythonFunction skipwhite')),
("Function","pythonFunction", "match",
contained('"[a-zA-Z_][a-zA-Z0-9_]*"')),
("Repeat", "pythonRepeat", "keyword", looping),
("Conditional", "pythonConditional", "keyword",
conditionals),
("Operator", "pythonOperator", "keyword", boolean_ops),
("PreCondit", "pythonPreCondit", "keyword", import_stmts),
("Comment", "pythonComment", "match",
'"#.*$" contains=pythonTodo'),
("Todo", "pythonTodo", "keyword",
contained(' '.join(todos))),
("String", "pythonString", "region", str_regexes()),
("Special", "pythonEscape", "match",
(contained(esc) for esc in escapes
if not '$' in esc)),
("Special", "pythonEscape", "match", r'"
\
\
$"'),
]
),
("python_highlight_numbers",
[("Number", "pythonNumber", "match", numbers)]
),
("python_highlight_builtins",
[("Function", "pythonBuiltin", "keyword", builtin_names)]
),
("python_highlight_exceptions",
[("Exception", "pythonException", "keyword",
exception_names)]
),
("python_highlight_space_errors",
[("Error", "pythonSpaceError", "match",
("display " + err for err in space_errors))]
)
)
def syn_prefix(type_, kind):
return 'syn %s %s ' % (type_, kind)
def fill_stmt(iterable, fill_len):
"""
Yield
a
string
that
fills
at
most
fill_len
characters
with
strings
returned
by
'iterable'
and
separated
by
a
space
"""
# Deal with trailing char to handle ' '.join() calculation
fill_len += 1
overflow = None
it = iter(iterable)
while True:
buffer_ = []
total_len = 0
if overflow:
buffer_.append(overflow)
total_len += len(overflow) + 1
overflow = None
while total_len < fill_len:
try:
new_item = next(it)
buffer_.append(new_item)
total_len += len(new_item) + 1
except StopIteration:
if buffer_:
break
if overflow:
yield overflow
return
if total_len > fill_len:
overflow = buffer_.pop()
total_len -= len(overflow) - 1
ret = ' '.join(buffer_)
assert len(ret) <= fill_len
yield ret
FILL = 80
def main(file_path):
with open(file_path, 'w') as FILE:
# Comment for file
print>>FILE, comment_header % subversion[1:]
print>>FILE, ''
# Statements at start of file
print>>FILE, statement_header
print>>FILE, ''
# Generate case for python_highlight_all
print>>FILE, 'if exists("python_highlight_all")'
for statement_var, statement_parts in statements:
if statement_var:
print>>FILE, ' let %s = 1' % statement_var
else:
print>>FILE, 'endif'
print>>FILE, ''
# Generate Python groups
for statement_var, statement_parts in statements:
if statement_var:
print>>FILE, 'if exists("%s")' % statement_var
indent = ' '
else:
indent = ''
for colour_group, group, type_, arguments in statement_parts:
if not isinstance(arguments, basestring):
prefix = syn_prefix(type_, group)
if type_ == 'keyword':
stmt_iter = fill_stmt(arguments,
FILL - len(prefix) - len(indent))
try:
while True:
print>>FILE, indent + prefix + next(stmt_iter)
except StopIteration:
print>>FILE, ''
else:
for argument in arguments:
print>>FILE, indent + prefix + argument
else:
print>>FILE, ''
else:
print>>FILE, indent + syn_prefix(type_, group) + arguments
print>>FILE, ''
else:
if statement_var:
print>>FILE, 'endif'
print>>FILE, ''
print>>FILE, ''
# Associating Python group with Vim colour group
for statement_var, statement_parts in statements:
if statement_var:
print>>FILE, ' if exists("%s")' % statement_var
indent = ' '
else:
indent = ' '
for colour_group, group, type_, arguments in statement_parts:
print>>FILE, (indent + "hi def link %s %s" %
(group, colour_group))
else:
if statement_var:
print>>FILE, ' endif'
print>>FILE, ''
# Statements at the end of the file
print>>FILE, statement_footer
if __name__ == '__main__':
main("python.vim")
Misc/Vim/vimrc
deleted
100644 → 0
View file @
2f095d3b
" vimrc file for following the coding standards specified in PEP 7 & 8.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
" in .py or .pyw will trigger the Python settings while files ending in *.c or
" *.h will trigger the C settings. This makes the file "safe" in terms of only
" adjusting settings for Python and C files.
"
" Only basic settings needed to enforce the style guidelines are set.
" Some suggested options are listed but commented out at the end of this file.
" Number of spaces that a pre-existing tab is equal to.
" For the amount of space used for a new tab use shiftwidth.
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=8
" What to use for an indent.
" This will affect Ctrl-T and 'autoindent'.
" Python: 4 spaces
" C: tabs (pre-existing files) or 4 spaces (new files)
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
fu Select_c_style()
if search('^\t', 'n', 150)
set shiftwidth=8
set noexpandtab
el
set shiftwidth=4
set expandtab
en
endf
au BufRead,BufNewFile *.c,*.h call Select_c_style()
au BufRead,BufNewFile Makefile* set noexpandtab
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h,*.rst match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
" Python: 79
" C: 79
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
" Turn off settings in 'formatoptions' relating to comment formatting.
" - c : do not automatically insert the comment leader when wrapping based on
" 'textwidth'
" - o : do not insert the comment leader when using 'o' or 'O' from command mode
" - r : do not insert the comment leader when hitting <Enter> in insert mode
" Python: not needed
" C: prevents insertion of '*' at the beginning of every line in a comment
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r
" Use UNIX (\n) line endings.
" Only used for new files so as to not force existing files to change their
" line endings.
" Python: yes
" C: yes
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
" ----------------------------------------------------------------------------
" The following section contains suggested settings. While in no way required
" to meet coding standards, they are helpful.
" Set the default file encoding to UTF-8: ``set encoding=utf-8``
" Puts a marker at the beginning of the file to differentiate between UTF and
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
" a binary file when executing the text file): ``set bomb``
" For full syntax highlighting:
"``let python_highlight_all=1``
"``syntax on``
" Automatically indent based on file type: ``filetype indent on``
" Keep indentation level from previous line: ``set autoindent``
" Folding based on indentation: ``set foldmethod=indent``
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment