rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
For method docs, see each method's docstrings. In general, there is a method of the same name to perform each SMTP command, and there is a method called 'sendmail' that will do an entire mail transaction. """ | See each method's docstrings for details. In general, there is a method of the same name to perform each SMTP command. There is also a method called 'sendmail' that will do an entire mail transaction. """ | def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)) |
SMTPRecipientsRefused The server rejected for ALL recipients | SMTPRecipientsRefused The server rejected ALL recipients | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. |
text = text.translate(self.whitespace_trans) | if isinstance(text, str): text = text.translate(self.whitespace_trans) elif isinstance(text, unicode): text = text.translate(self.unicode_whitespace_trans) | def _munge_whitespace(self, text): """_munge_whitespace(text : string) -> string |
entriesbygid = {} | def test_values(self): entries = grp.getgrall() entriesbyname = {} entriesbygid = {} | |
self.assertEqual(len(e), 4) self.assertEqual(e[0], e.gr_name) self.assert_(isinstance(e.gr_name, basestring)) self.assertEqual(e[1], e.gr_passwd) self.assert_(isinstance(e.gr_passwd, basestring)) self.assertEqual(e[2], e.gr_gid) self.assert_(isinstance(e.gr_gid, int)) self.assertEqual(e[3], e.gr_mem) self.assert_(isins... | self.check_value(e) entriesbygid.setdefault(e.gr_gid, []).append(e) entriesbyname.setdefault(e.gr_name, []).append(e) | def test_values(self): entries = grp.getgrall() entriesbyname = {} entriesbygid = {} |
entriesbyname.setdefault(e.gr_name, []).append(e) entriesbygid.setdefault(e.gr_gid, []).append(e) | def test_values(self): entries = grp.getgrall() entriesbyname = {} entriesbygid = {} | |
self.assert_(grp.getgrgid(e.gr_gid) in entriesbygid[e.gr_gid]) self.assert_(grp.getgrnam(e.gr_name) in entriesbyname[e.gr_name]) | e2 = grp.getgrgid(e.gr_gid) self.check_value(e2) self.assert_(max([self.valueseq(e2, x) \ for x in entriesbygid[e.gr_gid]])) e2 = grp.getgrnam(e.gr_name) self.check_value(e2) self.assert_(max([self.valueseq(e2, x) \ for x in entriesbyname[e.gr_name]])) | def test_values(self): entries = grp.getgrall() entriesbyname = {} entriesbygid = {} |
'initial value %r' % (maxcount,)) | 'initial value %r' % self.maxcount | def v(self): self.nonzero.acquire() if self.count == self.maxcount: raise ValueError, '.v() tried to raise semaphore count above ' \ 'initial value %r' % (maxcount,)) self.count = self.count + 1 self.nonzero.signal() self.nonzero.release() |
input = text_file.TextFile('Modules/Setup', join_lines=1) | def build_extensions(self): | |
while 1: line = input.readline() if not line: break line = line.split() remove_modules.append( line[0] ) input.close() | for filename in ('Modules/Setup', 'Modules/Setup.local'): input = text_file.TextFile(filename, join_lines=1) while 1: line = input.readline() if not line: break line = line.split() remove_modules.append(line[0]) input.close() | def build_extensions(self): |
'.mid': 'audio/midi', '.midi': 'audio/midi', | def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map | |
'.rtf': 'application/rtf', | def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map | |
for dirname in sys.path: fullname = os.path.join(dirname, 'profile.doc') if os.path.exists(fullname): sts = os.system('${PAGER-more} ' + fullname) if sts: print '*** Pager exit status:', sts break else: print 'Sorry, can\'t find the help file "profile.doc"', print 'along the Python search path.' | print "Documentation for the profile module can be found " print "in the Python Library Reference, section 'The Python Profiler'." | def help(): for dirname in sys.path: fullname = os.path.join(dirname, 'profile.doc') if os.path.exists(fullname): sts = os.system('${PAGER-more} ' + fullname) if sts: print '*** Pager exit status:', sts break else: print 'Sorry, can\'t find the help file "profile.doc"', print 'along the Python search path.' |
if platform in ('darwin', 'mac'): | if platform in ('darwin', 'mac') and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): | def build_extensions(self): |
if platform == 'darwin': | if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
elif o[-6:] == '.lproj': files = os.listdir(o) for f in files: if f[-4:] == '.nib': nibname = os.path.split(f)[1][:-4] cocoainfo = """ <key>NSMainNibFile</key> <string>%s</string> <key>NSPrincipalClass</key> <string>NSApplication</string>""" % nibname | def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[]): # First make sure the name ends in ".app" if destname[-4:] != '.app': destname = destname + '.app' # Now deduce the short name shortname = os.path.split(destname)[1] if shortname[-4:] == '.app': # Strip the .app suffix ... | |
stat_function = (os.stat, statcache.stat)[use_statcache] s1, s2 = _sig(stat_function(f1)), _sig(stat_function(f2)) if s1[0]!=stat.S_IFREG or s2[0]!=stat.S_IFREG: return 0 if shallow and s1 == s2: return 1 if s1[1]!=s2[1]: return 0 | if use_statcache: stat_function = statcache.stat else: stat_function = os.stat s1 = _sig(stat_function(f1)) s2 = _sig(stat_function(f2)) if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: return 0 if shallow and s1 == s2: return 1 if s1[1] != s2[1]: return 0 | def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return valu... |
print "path =", `path` if "/arse" in path: import pdb; pdb.set_trace() | def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path.""" | |
raise IOError(errno.EBADF, "write() on read-only GzipFile object") | raise IOError(errno.EBADF, "read() on write-only GzipFile object") | def read(self, size=-1): if self.mode != READ: import errno raise IOError(errno.EBADF, "write() on read-only GzipFile object") |
elif type(arg) == type(""): | elif isinstance(arg, basestring): | def load_stats(self, arg): if not arg: self.stats = {} elif type(arg) == type(""): f = open(arg, 'rb') self.stats = marshal.load(f) f.close() try: file_stats = os.stat(arg) arg = time.ctime(file_stats.st_mtime) + " " + arg except: # in case this is not unix pass self.files = [ arg ] elif hasattr(arg, 'create_stats... |
'lambda': ('ref/lambda', 'FUNCTIONS'), | 'lambda': ('ref/lambdas', 'FUNCTIONS'), | def writedocs(dir, pkgpath='', done=None): """Write out HTML documentation for all modules in a directory tree.""" if done is None: done = {} for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.', done) elif os.path.isfile(path): modname = inspect.getmodule... |
'pass': 'PASS', | 'pass': ('ref/pass', ''), | def writedocs(dir, pkgpath='', done=None): """Write out HTML documentation for all modules in a directory tree.""" if done is None: done = {} for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.', done) elif os.path.isfile(path): modname = inspect.getmodule... |
'EXECUTION': ('ref/execframes', ''), 'NAMESPACES': ('ref/execframes', 'global ASSIGNMENT DELETION'), | 'EXECUTION': ('ref/naming', ''), 'NAMESPACES': ('ref/naming', 'global ASSIGNMENT DELETION'), | 'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'), |
x = property(getx, setx, delx) | x = property(getx, setx, delx, doc="I'm the x property.") | def delx(self): del self.__x |
if not modname: | if not modname or '.' in modname: | def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import sch... |
np = lambda *f: norm(self.tempdir, *f) | def test_glob_literal(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a'), [self.norm('a')]) eq(self.glob('a', 'D'), [self.norm('a', 'D')]) eq(self.glob('aab'), [self.norm('aab')]) eq(self.glob('zymurgy'), []) | |
np = lambda *f: norm(self.tempdir, *f) | def test_glob_one_directory(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a*'), map(self.norm, ['a', 'aab', 'aaa'])) eq(self.glob('*a'), map(self.norm, ['a', 'aaa'])) eq(self.glob('aa?'), map(self.norm, ['aaa', 'aab'])) eq(self.glob('aa[ab]'), map(self.norm, ['aaa', ... | |
np = lambda *f: norm(self.tempdir, *f) | def test_glob_nested_directory(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) if os.path.normcase("abCD") == "abCD": # case-sensitive filesystem eq(self.glob('a', 'bcd', 'E*'), [self.norm('a', 'bcd', 'EF')]) else: # case insensitive filesystem eq(self.glob('a', 'bcd', 'E*'), [self.... | |
np = lambda *f: norm(self.tempdir, *f) | def test_glob_directory_names(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('*', 'D'), [self.norm('a', 'D')]) eq(self.glob('*', '*a'), []) eq(self.glob('a', '*', '*', '*a'), [self.norm('a', 'bcd', 'efg', 'ha')]) eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join(... | |
class Bottom: """A "card-like" object to serve as the bottom for some stacks. Specifically, this is used by the deck and the suit stacks. """ def __init__(self, stack): """Constructor, taking the stack as an argument. We displays ourselves as a gray rectangle the size of a playing card, positioned at the stack's ... | def bind(self, sequence=None, command=None): | |
turnover() -- turn the card (face up or down) & raise it onclick(handler), ondouble(handler), onmove(handler), onrelease(handler) -- set various mount event handlers reset() -- move the card out of sight, face down, and reset all event handlers Public instance variables: color, suit, value -- the card's color, suit a... | Public read-only instance variables: suit, value, color -- the card's suit, value and color | def __init__(self, stack): |
Semi-public instance variables (XXX should be made private): | Semi-public read-only instance variables (XXX should be made private): | def __init__(self, stack): |
is reversed.) | is reversed. The card is created face down.) | def __init__(self, stack): |
def __init__(self, game, suit, value): | def __init__(self, suit, value, canvas): """Card constructor. Arguments are the card's suit and value, and the canvas widget. The card is created at position (0, 0), with its face down (adding it to a stack will position it according to that stack's rules). """ | def __init__(self, game, suit, value): |
self.value = value canvas = game.canvas | self.face_shown = 0 | def __init__(self, game, suit, value): |
self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT, outline='black', fill='white') text = "%s %s" % (VALNAMES[value], suit) self.__text = CanvasText(canvas, CARDWIDTH/2, 0, anchor=N, fill=self.color, text=text) self.group = Group(canvas) | def __init__(self, game, suit, value): | |
self.group.addtag_withtag(self.__rect) self.group.addtag_withtag(self.__text) self.reset() | def __init__(self, game, suit, value): | |
return "Card(game, %s, %s)" % (`self.suit`, `self.value`) | return "Card(%s, %s)" % (`self.suit`, `self.value`) | def __repr__(self): |
dx = x - self.x dy = y - self.y | self.moveby(x - self.x, y - self.y) def moveby(self, dx, dy): """Move the card by (dx, dy).""" self.x = self.x + dx self.y = self.y + dy | def moveto(self, x, y): |
self.x = x self.y = y def moveby(self, dx, dy): self.moveto(self.x + dx, self.y + dy) | def moveto(self, x, y): | |
def turnover(self): if self.face_shown: self.showback() | class Stack: """A generic stack of cards. This is used as a base class for all other stacks (e.g. the deck, the suit stacks, and the row stacks). Public methods: add(card) -- add a card to the stack delete(card) -- delete a card from the stack showtop() -- show the top card (if any) face up deal() -- delete and ret... | def turnover(self): |
self.showface() def onclick(self, handler): self.group.bind('<1>', handler) def ondouble(self, handler): self.group.bind('<Double-1>', handler) def onmove(self, handler): self.group.bind('<B1-Motion>', handler) def onrelease(self, handler): self.group.bind('<ButtonRelease-1>', handler) def reset(self): self.moveto... | return if not card.face_shown: return self.moving = self.cards[i:] self.lastx = event.x self.lasty = event.y for card in self.moving: card.tkraise() def keepmoving(self, event): if not self.moving: return dx = event.x - self.lastx dy = event.y - self.lasty self.lastx = event.x self.lasty = event.y if dx or dy: for car... | def turnover(self): |
self.allcards.append(Card(self.game, suit, value)) self.reset() | self.add(Card(suit, value, self.game.canvas)) | def __init__(self, game): |
def deal(self): card = self.cards[-1] del self.cards[-1] return card def accept(self, card): if card not in self.cards: self.cards.append(card) def reset(self): self.cards = self.allcards[:] for card in self.cards: card.reset() | def userclickhandler(self): opendeck = self.game.opendeck card = self.deal() if not card: while 1: card = opendeck.deal() if not card: break self.add(card) card.showback() else: self.game.opendeck.add(card) card.showface() | def deal(self): |
class Stack: x = MARGIN y = MARGIN def __init__(self, game): self.game = game self.cards = [] def __repr__(self): return "<Stack at (%d, %d)>" % (self.x, self.y) def reset(self): self.cards = [] def acceptable(self, cards): return 1 def accept(self, card): self.cards.append(card) card.onclick(self.clickhandler) c... | class OpenStack(Stack): def usermovehandler(self, cards): card = cards[0] stack = self.game.closeststack(card) if not stack or stack is self or not stack.acceptable(cards): Stack.usermovehandler(self, cards) else: for card in cards: self.delete(card) stack.add(card) self.game.wincheck() def userdoubleclickhandler(sel... | def randperm(n): r = range(n) x = [] while r: i = random.choice(r) x.append(i) r.remove(i) return x |
self.game.turned.accept(card) del self.cards[-1] card.showface() def bottomhandler(self, event): cards = self.game.turned.cards cards.reverse() for card in cards: card.showback() self.accept(card) self.game.turned.reset() class MovingStack(Stack): thecards = None theindex = None def clickhandler(self, event): self.... | if not card.face_shown: self.userclickhandler() | def releasehandler(self, event): |
tag = tags[0] for i in range(len(self.cards)): card = self.cards[i] if tag == str(card.group): | for s in self.game.suits: if s.acceptable([card]): self.delete(card) s.add(card) self.game.wincheck() | def clickhandler(self, event): |
else: return self.theindex = i self.thecards = Group(self.game.canvas) for card in self.cards[i:]: self.thecards.addtag_withtag(card.group) self.thecards.tkraise() self.lastx = self.firstx = event.x self.lasty = self.firsty = event.y def movehandler(self, event): if not self.thecards: return card = self.cards[self.the... | class SuitStack(OpenStack): def makebottom(self): bottom = Rectangle(self.game.canvas, self.x, self.y, self.x+CARDWIDTH, self.y+CARDHEIGHT, outline='black', fill='') def userclickhandler(self): pass def userdoubleclickhandler(self): pass | def clickhandler(self, event): |
if not card.face_shown: return 0 | def acceptable(self, cards): | |
if not topcard.face_shown: return 0 | def acceptable(self, cards): | |
def doublehandler(self, event): pass def accept(self, card): MovingStack.accept(self, card) if card.value == KING: for s in self.game.suits: card = s.cards[-1] if card.value != KING: return self.game.win() self.game.deal() class RowStack(MovingStack): def __init__(self, game, i): self.index = i self.x = MARGIN + XS... | class RowStack(OpenStack): | def doublehandler(self, event): |
if card.value != topcard.value - 1: return 0 if card.color == topcard.color: return 0 return 1 | return card.color != topcard.color and card.value == topcard.value - 1 def position(self, card): y = self.y for c in self.cards: if c == card: break if c.face_shown: y = y + 2*MARGIN else: y = y + OFFSET card.moveto(self.x, y) | def acceptable(self, cards): |
self.buttonframe = Frame(self.master, background=BACKGROUND) self.buttonframe.pack(fill=X) self.dealbutton = Button(self.buttonframe, | self.canvas = Canvas(self.master, background=BACKGROUND, highlightthickness=0, width=NROWS*XSPACING, height=3*YSPACING + 20 + MARGIN) self.canvas.pack(fill=BOTH, expand=TRUE) self.dealbutton = Button(self.canvas, | def __init__(self, master): |
self.dealbutton.pack(side=LEFT) self.canvas = Canvas(self.master, background=BACKGROUND, highlightthickness=0, width=NROWS*XSPACING, height=3*YSPACING) self.canvas.pack(fill=BOTH, expand=TRUE) self.deck = Deck(self) | Window(self.canvas, MARGIN, 3*YSPACING + 20, window=self.dealbutton, anchor=SW) x = MARGIN y = MARGIN self.deck = Deck(x, y, self) x = x + XSPACING self.opendeck = OpenStack(x, y, self) | def __init__(self, master): |
self.pool = PoolStack(self) self.turned = TurnedStack(self) | x = x + XSPACING | def __init__(self, master): |
self.suits.append(SuitStack(self, i)) | x = x + XSPACING self.suits.append(SuitStack(x, y, self)) x = MARGIN y = y + YSPACING | def __init__(self, master): |
self.rows.append(RowStack(self, i)) | self.rows.append(RowStack(x, y, self)) x = x + XSPACING | def __init__(self, master): |
cards = self.deck.allcards | cards = [] for s in self.suits: cards = cards + s.cards if not cards: return | def win(self): |
def reset(self): self.pool.reset() self.turned.reset() for stack in self.rows + self.suits: stack.reset() self.deck.reset() | def reset(self): | |
r.accept(card) | r.add(card) | def deal(self): |
try: | def reset(self): for stack in [self.opendeck] + self.suits + self.rows: | def deal(self): |
self.pool.accept(self.deck.deal()) except IndexError: pass | card = stack.deal() if not card: break self.deck.add(card) card.showback() | def deal(self): |
if y.hasattr('__setstate__'): | if hasattr(y, '__setstate__'): | def _copy_inst(x): if hasattr(x, '__copy__'): return x.__copy__() if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() else: args = () y = apply(x.__class__, args) if hasattr(x, '__getstate__'): state = x.__getstate__() else: state = x.__dict__ if y.hasattr('__setstate__'): y.__setstate__(state) else: for key i... |
if y.hasattr('__setstate__'): | if hasattr(y, '__setstate__'): | def _deepcopy_inst(x, memo): if hasattr(x, '__deepcopy__'): return x.__deepcopy__() if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() args = deepcopy(args, memo) else: args = () y = apply(x.__class__, args) memo[id(x)] = y if hasattr(x, '__getstate__'): state = x.__getstate__() else: state = x.__dict__ state... |
libraries, library_dirs) | libraries, library_dirs, build_info) | def build_extensions (self, extensions): |
import Scrap | from Carbon import Scrap | def domenu_copy(self, *args): sel = self.getselectedobjects() selitems = [] for key, value, dummy, dummy in sel: selitems.append(double_repr(key, value)) text = string.join(selitems, '\r') if text: import Scrap Scrap.ZeroScrap() Scrap.PutScrap('TEXT', text) |
self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') | self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') | def test_rpartition(self): |
host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))).strip() req.add_header('Proxy-authorization', 'Basic ' + user_pass) | if not type or r_type.isdigit(): type = orig_type host = proxy else: host, r_host = splithost(r_type) user_pass, host = splituser(host) user, password = splitpasswd(user_pass) if user and password: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))).st... | def proxy_open(self, req, proxy, type): orig_type = req.get_type() type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))... |
self.d.GetDialogWindow().ShowWindow() | self.w.ShowWindow() | def __init__(self, title="Working...", maxval=100, label="", id=263): self.maxval = maxval self.curval = -1 self.d = GetNewDialog(id, -1) self.label(label) self._update(0) self.d.AutoSizeDialog() self.title(title) self.d.GetDialogWindow().ShowWindow() self.d.DrawDialog() |
self.d.BringToFront() self.d.HideWindow() | self.w.BringToFront() self.w.HideWindow() del self.w | def __del__( self ): self.d.BringToFront() self.d.HideWindow() del self.d |
w = self.d.GetDialogWindow() w.BringToFront() w.SetWTitle(newstr) | self.w.BringToFront() self.w.SetWTitle(newstr) | def title(self, newstr=""): """title(text) - Set title of progress window""" w = self.d.GetDialogWindow() w.BringToFront() w.SetWTitle(newstr) |
self.d.GetDialogWindow().BringToFront() | self.w.BringToFront() | def label( self, *newstr ): """label(text) - Set text in progress box""" self.d.GetDialogWindow().BringToFront() if newstr: self._label = lf2cr(newstr[0]) text_h = self.d.GetDialogItemAsControl(2) SetDialogItemText(text_h, self._label) |
return "-R" + dir | compiler = os.path.basename(sysconfig.get_config_var("CC")) if compiler == "gcc" or compiler == "g++": return "-Wl,-R" + dir else: return "-R" + dir | def runtime_library_dir_option (self, dir): return "-R" + dir |
tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration | if not self.tarfile._loaded: tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration else: try: tarinfo = self.tarfile.members[self.index] except IndexError: raise StopIteration self.index += 1 | def next(self): """Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. """ tarinfo = self.tarfile.next() if not tarinfo: self.tarfile._loaded = True raise StopIteration return tarinfo |
print "reinitialize_command: command=%s" % command print " before: have_run =", self.have_run | def reinitialize_command (self, command, reinit_subcommands=0): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied value... | |
print " after: have_run =", self.have_run | def reinitialize_command (self, command, reinit_subcommands=0): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied value... | |
print (" reinitializing sub-commands: %s" % command.get_sub_commands()) | def reinitialize_command (self, command, reinit_subcommands=0): """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied value... | |
if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") | try: if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") except KeyError, exc: raise DistutilsPlatformError, \ ("The .NET Framework SDK needs to be installed before " "building extensions for Python.") | def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot")... |
ad = self.getaddress() if ad: return ad + self.getaddrlist() else: return [] | result = [] while 1: ad = self.getaddress() if ad: result += ad else: break return result | def getaddrlist(self): """Parse all addresses. |
fullurl = unwrap(fullurl) | fullurl = unwrap(toBytes(fullurl)) | def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) i... |
type, url = splittype(fullurl) if not type: type = 'file' if self.proxies.has_key(type): proxy = self.proxies[type] type, proxyhost = splittype(proxy) | urltype, url = splittype(fullurl) if not urltype: urltype = 'file' if self.proxies.has_key(urltype): proxy = self.proxies[urltype] urltype, proxyhost = splittype(proxy) | def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) i... |
name = 'open_' + type self.type = type | name = 'open_' + urltype self.type = urltype | def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) i... |
url = unwrap(url) | url = unwrap(toBytes(url)) | def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename ... |
if type(url) is type(""): | if type(url) is types.StringType: | def open_http(self, url, data=None): """Use HTTP protocol.""" import httplib user_passwd = None if type(url) is type(""): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passw... |
if type(url) is type(""): | if type(url) in types.StringTypes: | def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) is type(""): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_pas... |
if os.sep != '/' and os.sep in pathname: raise ValueError, \ "path '%s' cannot contain '%c' character" % \ (pathname, os.sep) paths = string.split (pathname, '/') return apply (os.path.join, paths) | if os.sep != '/': if os.sep in pathname: raise ValueError, \ "path '%s' cannot contain '%c' character" % (pathname, os.sep) else: paths = string.split (pathname, '/') return apply (os.path.join, paths) | def native_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention... |
return s[:1] == '/' | return s.startswith('/') | def isabs(s): """Test whether a path is absolute""" return s[:1] == '/' |
if b[:1] == '/': | if b.startswith('/'): | def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path |
elif path == '' or path[-1:] == '/': path = path + b | elif path == '' or path.endswith('/'): path += b | def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path |
path = path + '/' + b | path += '/' + b | def join(a, *p): """Join two or more pathname components, inserting '/' as needed""" path = a for b in p: if b[:1] == '/': path = b elif path == '' or path[-1:] == '/': path = path + b else: path = path + '/' + b return path |
while head[-1] == '/': head = head[:-1] | head = head.rstrip('/') | def split(p): """Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.""" i = p.rfind('/') + 1 head, tail = p[:i], p[i:] if head and head != '/'*len(head): while head[-1] == '/': head = head[:-1] return head, tail |
if path[:1] != '~': | if not path.startswith('~'): | def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HO... |
i = i + 1 | i += 1 | def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HO... |
userhome = pwd.getpwuid(os.getuid())[5] | userhome = pwd.getpwuid(os.getuid()).pw_dir | def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HO... |
userhome = pwent[5] if userhome[-1:] == '/': i = i + 1 | userhome = pwent.pw_dir if userhome.endswith('/'): i += 1 | def expanduser(path): """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] != '/': i = i + 1 if i == 1: if not 'HOME' in os.environ: import pwd userhome = pwd.getpwuid(os.getuid())[5] else: userhome = os.environ['HO... |
if name[:1] == '{' and name[-1:] == '}': | if name.startswith('{') and name.endswith('}'): | def expandvars(path): """Expand shell variables of form $var and ${var}. Unknown variables are left unchanged.""" global _varprog if '$' not in path: return path if not _varprog: import re _varprog = re.compile(r'\$(\w+|\{[^}]*\})') i = 0 while True: m = _varprog.search(path, i) if not m: break i, j = m.span(0) name =... |
path = path + tail | path += tail | def expandvars(path): """Expand shell variables of form $var and ${var}. Unknown variables are left unchanged.""" global _varprog if '$' not in path: return path if not _varprog: import re _varprog = re.compile(r'\$(\w+|\{[^}]*\})') i = 0 while True: m = _varprog.search(path, i) if not m: break i, j = m.span(0) name =... |
main() | def testtype(type, example): a = array.array(type) a.append(example) if verbose: print 40*'*' print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): a.byteswap() if a.typecode == 'c': f = open(TESTFN, "w") f.write("The quick brown fox jumps over the lazy dog.\n") f.close() f = op... | |
def test_warning(self): warnings.filterwarnings("error", category=RuntimeWarning, message="mktemp") self.assertRaises(RuntimeWarning, tempfile.mktemp, (), { 'dir': self.dir }) | def test_warning(self): # mktemp issues a warning when used warnings.filterwarnings("error", category=RuntimeWarning, message="mktemp") self.assertRaises(RuntimeWarning, tempfile.mktemp, (), { 'dir': self.dir }) | |
return self.socket.recvfrom(max_packet_size) | return self.socket.recvfrom(self.max_packet_size) | def get_request(self): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.