rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print_decls(depdecls)
print_decls(decls, 'deprecated')
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
if not export_deprecated and d.body.find('<DEPRECATED/>'):
if not export_deprecated and d.body.find('<DEPRECATED/>') > -1:
def __init__(self, mapping): self.__dict__.update(mapping)
mean_value = (min(a) + max(a))/2.0
mirror = min(a) + max(a)
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mean_value = (min(a) + max(a))/2.0 for i in range(n): a[i] = mean_value - a[i] Gwyddion.dump.write(data, filename)
a[i] = mean_value - a[i]
a[i] = mirror - a[i]
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mean_value = (min(a) + max(a))/2.0 for i in range(n): a[i] = mean_value - a[i] Gwyddion.dump.write(data, filename)
makefile = get_file('Makefile.am')
try: makefile = get_file('Makefile.am') except IOError: return
def recurse(each): cwd = os.getcwd() makefile = get_file('Makefile.am') each(makefile) subdirs = get_list(makefile, 'SUBDIRS') for s in subdirs: os.chdir(s) recurse(each) os.chdir(cwd)
for i, t in enumerate(tokens):
for t in tokens:
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for i, t in enumerate(tokens): if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue prec = tokens[i-1] mbefore = prec.line...
prec = tokens[i-1] mbefore = prec.line == t.line and prec.end == t.col succ = tokens[i+1] mafter = succ.line == t.line and t.end == succ.col
mbefore = t.prec.line == t.line and t.prec.end == t.col mafter = t.succ.line == t.line and t.end == t.succ.col
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for i, t in enumerate(tokens): if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue prec = tokens[i-1] mbefore = prec.line...
for i, t in enumerate(tokens):
for t in tokens:
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %...
succ = tokens[i+1] if succ.line == t.line and t.end == succ.col:
if t.succ.line == t.line and t.end == t.succ.col:
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %...
for i, t in enumerate(tokens):
for t in tokens:
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue prec = tokens[i-1] if prec.line == t.line and prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warn...
prec = tokens[i-1] if prec.line == t.line and prec.end == t.col:
if t.prec.line == t.line and t.prec.end == t.col:
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue prec = tokens[i-1] if prec.line == t.line and prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warn...
for i, t in enumerate(tokens):
for t in tokens:
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for i, t in enumerate(tokens): if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')': w = 'Opening...
prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')':
if t.line > t.prec.line and t.prec.typ == Token.punct \ and t.prec.string == ')':
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for i, t in enumerate(tokens): if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')': w = 'Opening...
for i, t in enumerate(tokens):
for t in tokens:
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.ident or t.string not in keywords: continue succ = tokens[i+1] if succ.line == t.li...
succ = tokens[i+1] if succ.line == t.line and t.end == succ.col:
if t.succ.line == t.line and t.end == t.succ.col:
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.ident or t.string not in keywords: continue succ = tokens[i+1] if succ.line == t.li...
for i, t in enumerate(tokens):
for t in tokens:
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col ...
try: succ = tokens[i+1] except IndexError: break if succ.line == t.line:
if t.succ.line == t.line:
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col ...
warnings.append((t.line, w % (succ.col, lines[t.line])))
warnings.append((t.line, w % (t.succ.col, lines[t.line])))
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col ...
for i, t in enumerate(tokens):
for t in tokens:
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
succ = tokens[i+1]
succ = t.succ
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
succ = tokens[i+2]
succ = succ.succ
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
prec = tokens[i-1]
prec = t.prec
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
prec = tokens[prec.matching-1]
prec = prec.matching.prec
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '('
succ = t.succ if succ.typ != Token.punct or succ.string != '(': continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
succ = tokens[m+1]
succ = m.succ
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
succ = tokens[m+2] if succ.line > tokens[m].line:
succ = succ.succ if succ.line > m.line:
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ ==...
for i, t in enumerate(tokens):
for t in tokens:
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for i, t in enumerate...
if t.line == tokens[i+1].line:
if t.line == t.succ.line:
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for i, t in enumerate...
for i, t in enumerate(tokens):
for t in tokens:
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct ...
prec = tokens[i-1]
prec = t.prec
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct ...
if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(':
if prec.line == t.line and prec.end == t.col or prec.line < t.line: continue m = t.matching.succ if m.typ == Token.punct and m.string == '(':
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct ...
for i, t in enumerate(tokens):
for t in tokens:
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != '(': continue if not i or tokens[i-1].string not in keywords: continue w = 'Extra return/case/goto parentheses...
if not i or tokens[i-1].string not in keywords:
if t.prec.string not in keywords: continue if t.matching.succ.typ != Token.punct or t.matching.succ.string != ';':
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != '(': continue if not i or tokens[i-1].string not in keywords: continue w = 'Extra return/case/goto parentheses...
for i, t in enumerate(tokens): if not i or tokens[i].string not in keywords: continue if tokens[i-1].typ != Token.punct or (tokens[i-1].string != '!=' and tokens[i-1].string != '=='):
for t in tokens: if t.string not in keywords: continue prec = t.prec if prec.typ != Token.punct or (prec.string != '!=' and prec.string != '=='):
def check_boolean_comparisons(tokens, lines, warnings): keywlist = 'TRUE', 'FALSE' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if not i or tokens[i].string not in keywords: continue if tokens[i-1].typ != Token.punct or (tokens[i-1].string != '!=' and tokens[i-1].string != '=='): continue ...
tokens[p].matching = i
p.matching = t
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p tokens[p].matching = i t.parenlevel = l...
stacks[t.string].append(i)
stacks[t.string].append(t)
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p tokens[p].matching = i t.parenlevel = l...
re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LU]*\b')
re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?[FfLl]?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LlUu]*\b')
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too ...
if t.succ.line == t.line:
if t.succ and t.succ.line == t.line:
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for t in tokens: if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue if t.succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (t.succ.col, lines[t.li...
k = re.sub(r'_1_1', '_1:1', k) words = k.split('_')
words = re.sub(r'_1_1', '_1:1', k).split('_')
def update_documentation(images): """Update `documentation' in C source to list all stock icons.""" # Format documentation entries # Note the `../' in image path. It is here to undo the effect of content # files being XIncluded from xml/ subdirectory, therefore straight paths # get xml/ prepended to be relative to th...
re_enum = re.compile(r'^\s+(?P<ident>[A-Z][A-Z0-9_]+)\s*[=,]', re.M)
re_enum = re.compile(r'^\s+(?P<ident>[A-Z][A-Z0-9_]+)\b', re.M)
command -nargs=+ HiLink hi def link <args>
assert c == '['
if not c: return False if c != '[': fh.seek(-1, 1) return False
def _read_dfield(fh, data, base): c = fh.read(1) assert c == '[' dfield = {} _dmove(data, base + '/xres', dfield, 'xres', int) _dmove(data, base + '/yres', dfield, 'yres', int) _dmove(data, base + '/xreal', dfield, 'xreal', float) _dmove(data, base + '/yreal', dfield, 'yreal', float) _dmove(data, base + '/unit-xy', dfi...
if m: _read_dfield(fh, data, m.group('key'))
if m and _read_dfield(fh, data, m.group('key')):
def read(filename): """Read a Gwyddion plug-in proxy dump file. The file is returned as a dictionary of dump key, value pairs. Data fields are packed into dictionaries with following keys (not all has to be present): `xres', x-resolution (number of samples), `yres', y-resolution (number of samples), `xreal', real x s...
LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS
LIB_HEADERS: install rules, filled from lib_LTLIBRARIES, fooinclude_HEADERS
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this varia...
return name + ' =' + format_list(lst)
list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\include\$(LIBDIR)"' % x) for x in lst] inst_part = '\n\t'.join(['install-headers:'] + inst_part) return list_part + '\n\n' + inst_part
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this varia...
re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\|')
re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\||\+\+|--|\*\*+|\.\.\.')
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too ...
inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x)
inst_part = [('$(INSTALL) %s "$(DEST_DIR)\data\$(DATA_TYPE)"' % x)
def expand_template(makefile, name): if name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + ' \\\n\t'.join([''] + lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part ...
_python_version = int, sys.version.split()[0].split('.')
_python_version = sys.version.split()[0].split('.')
def DBPRINT(*args): print ' '.join(args)
handlers.append( urllib2.FTPHandler() ) if not (keepalive_handler and self.opts.keepalive):
if not need_keepalive_handler:
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.pr...
if keepalive_handler and self.opts.keepalive:
if need_keepalive_handler:
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.pr...
if range_handlers and (self.opts.range or self.opts.reget):
if need_range_handler:
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.pr...
raise
def setUp(self): self.url = ref_proftp try: fo = urllib2.urlopen(self.url).close() except IOError: raise self.skip()
Return a string of the form "bytes=<firstbyte>-<lastbyte>".
Return a string of the form "bytes=<firstbyte>-<lastbyte>" or None if no range is needed.
def range_tuple_to_header(range_tup): """Convert a range tuple to a Range header value. Return a string of the form "bytes=<firstbyte>-<lastbyte>". """ if range_tup is None: return None range_tup = range_tuple_normalize(range_tup) if range_tup: if range_tup[1]: range_tup = (range_tup[0],range_tup[1] - 1) return 'bytes=...
filename = os.path.basename( path )
if scheme in [ 'http', 'https' ]: filename = os.path.basename( urllib.unquote(path) ) else: filename = os.path.basename( path )
def urlgrab(self, url, filename=None, **kwargs): """grab the file at <url> and make a local copy at <filename> If filename is none, the basename of the url is used. urlgrab returns the filename of the local file, which may be different from the passed-in filename if copy_local == 0. """ opts = self.opts.derive(**kwargs...
except socket.error:
except socket.error, e:
def _fill_buffer(self, amt=None): """fill the buffer to contain at least 'amt' bytes by reading from the underlying file object. If amt is None, then it will read until it gets nothing more. It updates the progress meter and throttles after every self._rbufsize bytes.""" # the _rbuf test is only in this first 'if' fo...
if isinstance(e.reason, TimeoutError):
if hasattr(e, 'reason') and isinstance(e.reason, TimeoutError):
def _make_request(self, req, opener): try: if have_socket_timeout and self.opts.timeout: old_to = socket.getdefaulttimeout() socket.setdefaulttimeout(self.opts.timeout) try: fo = opener.open(req) finally: socket.setdefaulttimeout(old_to) else: fo = opener.open(req) hdr = fo.info() except ValueError, e: raise URLGrabErr...
user_password, host = string.split(host, '@', 1) user, password = string.split(user_password, ':', 1)
user_password, host = urllib2.splituser(host) user, password = urllib2.splitpasswd(user_password)
def _parse_url(self,url): """break up the url into its component parts
self.cache_openers = True
def _set_defaults(self): """Set all options to their default values. When adding new options, make sure a default is provided here. """ self.progress_obj = None self.throttle = 1.0 self.bandwidth = 0 self.retry = None self.retrycodes = [-1,2,4,5,6,7] self.checkfunc = None self.copy_local = 0 self.close_connection = 0 s...
self._opener = urllib2.build_opener(*handlers)
if self.opts.cache_openers: self._opener = CachedOpenerDirector(*handlers) else: self._opener = urllib2.build_opener(*handlers)
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.pr...
s = fo.read(limit)
if limit is None: s = fo.read() else: s = fo.read(limit)
def retryfunc(opts, url, limit): fo = URLGrabberFileObject(url, filename=None, opts=opts) s = '' try: s = fo.read(limit) if not opts.checkfunc is None: if callable(opts.checkfunc): func, args, kwargs = opts.checkfunc, (), {} else: func, args, kwargs = opts.checkfunc apply(func, (s, )+args, kwargs) finally: fo.close() r...
if p.endswith('/') or url.startswith('/'): url = p + url
if p[-1] == '/' or url[0] == '/': url = p + url
def _parse_url(self,url): """break up the url into its component parts
raise URLError('file not on local host')
raise urllib2.URLError('file not on local host')
def open_local_file(self, req): import mimetypes import mimetools host = req.get_host() file = req.get_selector() localfile = urllib.url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] if host: host, port = url...
raise URLError(msg)
raise urllib2.URLError(msg)
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) if port is None: port = ftplib.FTP_PORT
user_password, host = user_pass, host = host.split('@', 1)
user_pass, host = host.split('@', 1)
def _parse_url(self,url): """break up the url into its component parts
self._opener = CachedOpenerDirector(*handlers)
self._opener = urllib2.build_opener(*handlers) self._opener.addheaders = []
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self...
return self.parent.error('http', req, r, r.status, r.reason, r.msg)
return self.parent.error('http', req, r, r.status, r.msg, r.headers)
def do_open(self, http_class, req): host = req.get_host() if not host: raise urllib2.URLError('no host given')
return self.msg
return self.headers
def info(self): return self.msg
tuple, it is enterpreted to be of the form (cb, args, kwargs)
tuple, it is interpreted to be of the form (cb, args, kwargs)
def _(st): return st
itself. The callback will be passed exception that was raised (and args and kwargs if present).
itself. The callback will be passed the exception that was raised (and args and kwargs if present).
def _(st): return st
y = (x)
y = (x,)
def testIdentity(self): # test to make sure that objects retain identity properly x = [] y = (x) x.append(y) x.append(y) self.assertIdentical(x[0], x[1]) self.assertIdentical(x[0][0], x) d = self.encode(x) d.addCallback(self.shouldDecode) d.addCallback(self._testIdentity_1) return d
faces = { 'times': 'Times', 'mono' : 'Courier', 'helv' : 'Helvetica', 'other': 'new century schoolbook', 'size' : 12, 'size2': 10, }
faces = { 'times': 'Times', 'mono' : 'Courier', 'helv' : 'Helvetica', 'other': 'new century schoolbook', 'size' : 10, 'size2': 8, }
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
self.SetLexer(wx.stc.STC_LEX_PYTHON) self.SetKeyWords(0, " ".join(keyword.kwlist))
self.SetLexer(wx.stc.STC_LEX_CPP) self.SetKeyWords(0, " ".join(SC3_KEYWORDS))
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.SetMargins(0,0)
self.SetMargins(1,0)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "back:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_DEFAULT, "fore:
self.StyleSetSpec(stc.STC_C_DEFAULT, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:
self.StyleSetSpec(stc.STC_C_COMMENTLINE, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_NUMBER, "fore:
self.StyleSetSpec(stc.STC_C_NUMBER, "bold,fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_STRING, "fore:
self.StyleSetSpec(stc.STC_C_STRING, "italic,fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_CHARACTER, "fore:
self.StyleSetSpec(stc.STC_C_CHARACTER, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_WORD, "fore: self.StyleSetSpec(stc.STC_P_TRIPLE, "fore: self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, "fore: self.StyleSetSpec(stc.STC_P_CLASSNAME, "fore: self.StyleSetSpec(stc.STC_P_DEFNAME, "fore:
self.StyleSetSpec(stc.STC_C_WORD, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_OPERATOR, "bold,size:%(size)d" % faces)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_IDENTIFIER, "fore: self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, "fore:
self.StyleSetSpec(stc.STC_C_IDENTIFIER, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
self.StyleSetSpec(stc.STC_P_STRINGEOL, "fore:
self.StyleSetSpec(stc.STC_C_STRINGEOL, "fore:
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_P_OPERATOR:
if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_C_OPERATOR:
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR:
if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_C_OPERATOR:
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy();
def OnOpenFile(self,evt): fileDlg = wx.FileDialog(self,style=wx.OPEN) if fileDlg.ShowModal( ) == wx.ID_OK: path = fileDlg.GetPath() self.OpenFile(path)
self.OnSaveFileInWin(self,evt,activeWin)
self.OnSaveFileInWin(evt,activeWin)
def OnSaveFile(self,evt): activeWin = self.GetActiveChild( ); self.OnSaveFileInWin(self,evt,activeWin)
sel = string.strip(str(activeChild.GetSelectedText()))
if not activeChild == self.logWin: sel = string.strip(str(activeChild.GetSelectedText())) else : sel = ""
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [g...
for helpFolder in [gAppHelpFolder,gHelpFolder]:
for helpFolder in [gHelpFolder]:
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [g...
foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf")
foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf")
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [g...
gHelpFolder = 'Help'
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
import PySCLang, os, string, keyword, sys
import wx.html as html import PySCLang import os, string, keyword, sys
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
ID_AccelF2 = wx.NewId() ID_AccelF2 = wx.NewId() ID_AccelF3 = wx.NewId() ID_AccelF4 = wx.NewId() ID_AccelF5 = wx.NewId() ID_AccelF6 = wx.NewId() ID_AccelF7 = wx.NewId() ID_AccelF8 = wx.NewId() ID_AccelF9 = wx.NewId() ID_AccelF10 = wx.NewId() ID_AccelF11 = wx.NewId() ID_AccelF12 = wx.NewId()
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
self.SetEdgeMode(stc.STC_EDGE_BACKGROUND) self.SetEdgeColumn(78)
self.SetUseAntiAliasing(True)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_...
menu2 = wx.Menu() menu2.Append(ID_AccelF2, "Simulate\tF&2") menu2.Append(ID_AccelF3, "Simulate\tF&3") menu2.Append(ID_AccelF4, "Simulate\tF&4") menu2.Append(ID_AccelF5, "Simulate\tF&5") menu2.Append(ID_AccelF6, "Simulate\tF&6") menu2.Append(ID_AccelF7, "Simulate\tF&7") menu2.Append(ID_AccelF8, "Simulate\tF&8") menu2.Ap...
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
menubar.Append(menu2, "&Debug")
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
self.Bind(wx.EVT_MENU, self.OnAccelF2, id=ID_AccelF2) self.Bind(wx.EVT_MENU, self.OnAccelF3, id=ID_AccelF3) self.Bind(wx.EVT_MENU, self.OnAccelF4, id=ID_AccelF4) self.Bind(wx.EVT_MENU, self.OnAccelF5, id=ID_AccelF5) self.Bind(wx.EVT_MENU, self.OnAccelF6, id=ID_AccelF6) self.Bind(wx.EVT_MENU, self.OnAccelF7, id=ID_Accel...
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
accelTableEntries.append(wx.AcceleratorEntry(wx.ACCEL_NORMAL,wx.WXK_F2,ID_AccelF2)) accelTableEntries.append(wx.AcceleratorEntry(wx.ACCEL_NORMAL,wx.WXK_F3,ID_AccelF3)) accelTableEntries.append(wx.AcceleratorEntry(wx.ACCEL_NORMAL,wx.WXK_F4,ID_AccelF4)) accelTableEntries.append(wx.AcceleratorEntry(wx.ACCEL_NORMAL,wx.WXK_...
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
self.OpenFile("C:\\Documents and Settings\\golinvauxb\\Bureau\\____FOR SCWIN USERS____\\STUFF TO TRY\\test808.sc") self.OpenFile("C:\\Documents and Settings\\golinvauxb\\Bureau\\____FOR SCWIN USERS____\\STUFF TO TRY\\test1.sc") self.OpenFile("C:\\Documents and Settings\\golinvauxb\\Bureau\\____FOR SCWIN USERS____\\STUF...
self.OpenFile("C:\\SOMEWHERE\\test.sc")
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
def OnAccelF2(self,evt): self.OnArrangeWindows(evt) def OnAccelF3(self,evt): wx.MessageBox("OnAccelF3") def OnAccelF4(self,evt): wx.MessageBox("OnAccelF4") def OnAccelF5(self,evt): wx.MessageBox("OnAccelF5") def OnAccelF6(self,evt): wx.MessageBox("OnAccelF6") def OnAccelF7(self,evt): wx.MessageBox("OnAccelF7") d...
def OnAccelF2(self,evt): #wx.MessageBox("OnAccelF2") self.OnArrangeWindows(evt)
if sel == "-" : sel = "subtraction" elif sel == "/" : sel = "division" elif sel == "*" : sel = "(W32) multiplication" elif sel == "**": sel = "(W32) exponentiation" elif sel == "<" : sel = "(W32) less than" elif sel == "<=": sel = "(W32) less than or equal" elif sel == ">" : sel = "(W32) greater than" elif sel == ">=...
if sel == "-" : sel = "subtraction" elif sel == "/" : sel = "division" elif sel == "*" : sel = "multiplication" elif sel == "**": sel = "exponentiation" elif sel == "<" : sel = "lessthan" elif sel == "<=": sel = "lessthanorequal" elif sel == ">" : sel = "greaterthan" elif sel == ">=": sel = "greaterthanorequal"
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" ...