rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if channels[x] == CHKCHANNEL: | if string.upper(channels[x]) == string.upper(CHKCHANNEL): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!say': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!say'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!topic': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!topic'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!kick': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!kick'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if ischanmember(msg[4]): | if ischanmember(string.upper(msg[4])): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!join': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!join'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!cycle': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!cycle'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
if string.lstrip(msg[3], ':') == '!quit': | if string.upper(string.lstrip(msg[3], ':')) == string.upper('!quit'): | def ischanmember(CHKCHANNEL): print "ischanmember Called" x = 0 print "Starting the loop" while (len(channels)-1 >= x): print "The loop is checking if we are in channels[" + str(x) + "] which is " + channels[x] if channels[x] == CHKCHANNEL: print "We are in it!" return 1 else: #Keep going! x = x+1 print "No match yet" ... |
partmessage = ' '.join(msg[4:]) if privcheck(HOSTMASK): print "Parting!" irccommand("PRIVMSG " + CHANNEL + " :buh-bye now! =)") irccommand("PART " + CHANNEL + " :Part from %s" % nick_name) elif privcheck(HOSTMASK): print "Parting!" irccommand("PRIVMSG " + CHANNEL + " :buh-bye now! =)") irccommand("PART " + CHANNEL + " ... | if privcheck(HOSTMASK): if len(msg) > 4: if msg[4][0] == " print "Parting!" irccommand("PRIVMSG " + msg[4] + " :buh-bye now! =)") irccommand("PART " + msg[4] + " :Part from %s" % nick_name) remchan(msg[4]) else: irccommand("PRIVMSG " + CHANNEL + " :" + msg[4] + " is not a channel") else: irccommand("PRIVMSG " + CHANNEL... | #def isusingprefix(INDATA,COMMAND): |
REALNAME = '' | REALNAME = 'The Internet Chat Relay Bot Project' | def addprefix(PREFIX): prefixes.append(PREFIX) |
print "Oh yay it worked!" | irccommand("JOIN " + msg[2]) | #def isusingprefix(INDATA,COMMAND): |
remchan(msg[3]). | remchan(msg[3]) | #def isusingprefix(INDATA,COMMAND): |
y = y + d * math.sin(-math.pi * (90. + self.a) / 180.) x = x + d * math.cos(-math.pi * (90. + self.a) / 180.) | y = y + d * math.sin(math.pi * self.a / 180.) x = x + d * math.cos(math.pi * self.a / 180.) | def draw(self): t = self.app.ts() |
x = posixpath.basename(g[i]) tasks.append(x[:-3]) | type = pyfile_type(g[i]) if type is 'task' or type is None: x = posixpath.basename(g[i]) tasks.append(x[:-3]) | def add_tasks(self, menubar, dropname, dir): import glob menubar.addmenu(dropname, '', '') if dir[-1] == '/': g = glob.glob(dir+'*.py') else: g = glob.glob(dir+'/*.py') tasks = [] for i in range(0, len(g)): x = posixpath.basename(g[i]) tasks.append(x[:-3]) tasks.sort() |
stats = book.add('stats') | def __init__(self, gui=1, psych=0): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. The DA... | |
("Block Params", None, None), | ("Blocking Params", None, None), ("max_ntrials", "0", is_int, " ("max_correct", "0", is_int, " ("max_ui", "0", is_int, " ("Old Blocking Params", None, None), ("uimax", "3", is_int, "maximum | def __init__(self, gui=1, psych=0): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. The DA... |
("uimax", "3", is_iparam, "maximum | def __init__(self, gui=1, psych=0): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. The DA... | |
self.stats = Label(stats, text='', anchor=W, justify=LEFT) self.stats.pack(expand=0, fill=BOTH, side=TOP) self._block_update(clear=1) | self._runstats_update(clear=1) | def __init__(self, gui=1, psych=0): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. The DA... |
if type: if type[0] == 'C': self._block_update(correct=1) elif type[0] == 'E': self._block_update(error=1) else: self._block_update(other=1) | self._runstats_update(type[0]) | def set_result(self, type): # combination of self.tally() and self.history() self.history(type[0]) self.tally(type=type) if type: if type[0] == 'C': self._block_update(correct=1) elif type[0] == 'E': self._block_update(error=1) else: self._block_update(other=1) |
self.stats.configure(\ text='ncorrect = %d / %d\nnerrors = %d\nnother = %d' % \ (self.blockstats['ncorrect'], self.sub_common.queryv('blocksize'), self.blockstats['nerrors'], self.blockstats['nother'])) | def tally(self, type=None, clear=None, cleartask=None): ctask = self.task_name if clear: # clear everything self.tallycount = {} elif cleartask: # just clear current task data for (task,type) in self.tallycount.keys(): if ctask == task: del self.tallycount[(task,type)] elif type: # add new data to current task stats tr... | |
def _block_update(self, clear=None, \ correct=None, error=None, other=None): if clear: self.blockstats = {} self.blockstats['ncorrect'] = 0 self.blockstats['nerrors'] = 0 self.blockstats['nother'] = 0 else: if correct is not None: self.blockstats['ncorrect'] = self.blockstats['ncorrect'] + 1 elif error is not None: sel... | def _runstats_update(self, clear=None, resultcode=None): if clear is not None: self._runstats = {} self._runstats['ncorrect'] = 0 self._runstats['nerror'] = 0 self._runstats['nother'] = 0 self._runstats['nui'] = 0 elif resultcode is not None: r = resultcode[0] if r is 'C': self._runstats['ncorrect'] = self._runstats[... | def _block_update(self, clear=None, \ correct=None, error=None, other=None): if clear: self.blockstats = {} self.blockstats['ncorrect'] = 0 self.blockstats['nerrors'] = 0 self.blockstats['nother'] = 0 else: if correct is not None: self.blockstats['ncorrect'] = self.blockstats['ncorrect'] + 1 elif error is not None: sel... |
warn('Block Complete', '%d correct trials. Block done.' % bs, wait=0) def trial_ui(self, uimax=1000): | warn('Run Complete', '%d total trials trials. Stopping.' % n, wait=0) nmax = self.sub_common.queryv('max_correct') n = self._runstats['ncorrect'] if (nmax > 0) and n > nmax: self.set_state(running=0) warn('Run Complete', '%d correct trials trials. Stopping.' % n, wait=0) nmax = self.sub_common.queryv('max_ui') n = se... | def _block_update(self, clear=None, \ correct=None, error=None, other=None): if clear: self.blockstats = {} self.blockstats['ncorrect'] = 0 self.blockstats['nerrors'] = 0 self.blockstats['nother'] = 0 else: if correct is not None: self.blockstats['ncorrect'] = self.blockstats['ncorrect'] + 1 elif error is not None: sel... |
def trial_ui(self, uimax=1000): """This trial was un-initiated..""" self.trialstats['uicount'] = self.trialstats['uicount'] + 1 if uimax and (self.trialstats['uicount'] > uimax): warn('Warning', 'UI Count exceeded.\nTime: %s\nPlease intervene.\n' % Timestamp(), wait=1) self.trialstats['uicount'] = 0 | def trial_correct(self, correct): """This trial was correct...""" if correct: self.trialstats['ncorrect'] = self.trialstats['ncorrect'] + 1 self.trialstats['ntrials'] = self.trialstats['ntrials'] + 1 self.trialstats['uicount'] = 0 | |
self._block_update(clear=1) | self._runstats_update(clear=1) | def _start_helper(self, temp=None, train=None): self._savestate() if self.startfn: if not self.running: self._loadmenu.disableall() if int(self.rig_common.query('testing')): if ask("pype", "testing mode ok?", ("yes", "no")) == 1: return if temp: fname = './%s.tmp' % self.uname if posixpath.exists(fname): posix.unlink(... |
if pygame.display.iconify(): | if self._fullscreen: pygame.display.toggle_fullscreen() pygame.display.iconify() | def hide(self): """Iconify framebuffer Hide (ie, iconify) the graphics display. This really only works in non-fullscreen mode. """ if pygame.display.iconify(): self._fullscreen = 0 |
if pygame.display.toggle_fullscreen(): | if not self._fullscreen: pygame.display.toggle_fullscreen() | def show(self): """De-iconify framebuffer Restore (ie, de-iconify) the graphics display. This really only works in non-fullscreen mode. """ if pygame.display.toggle_fullscreen(): self._fullscreen = 1 |
_block_update(correct=1) | self._block_update(correct=1) | def set_result(self, type): # combination of self.tally() and self.history() self.history(type[0]) self.tally(type=type) if type: if type[0] == 'C': _block_update(correct=1) elif type[0] == 'E': _block_update(error=1) else: _block_update(other=1) |
_block_update(error=1) | self._block_update(error=1) | def set_result(self, type): # combination of self.tally() and self.history() self.history(type[0]) self.tally(type=type) if type: if type[0] == 'C': _block_update(correct=1) elif type[0] == 'E': _block_update(error=1) else: _block_update(other=1) |
_block_update(other=1) | self._block_update(other=1) | def set_result(self, type): # combination of self.tally() and self.history() self.history(type[0]) self.tally(type=type) if type: if type[0] == 'C': _block_update(correct=1) elif type[0] == 'E': _block_update(error=1) else: _block_update(other=1) |
_block_update(clear=1) | self._block_update(clear=1) | def _start_helper(self, temp=None, train=None): self._savestate() if self.startfn: if not self.running: self._loadmenu.disableall() if int(self.rig_common.query('testing')): if ask("pype", "testing mode ok?", ("yes", "no")) == 1: return if temp: fname = './%s.tmp' % self.uname if posixpath.exists(fname): posix.unlink(... |
("eyetracker", "iscan", is_any, "", -1), ("eyefreq", "120", is_int), | ("eyetracker", "", is_any, "", -1), ("eyefreq", "", is_int), | def __init__(self, framebuffer=1, gui=1): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. ... |
b = Button(cpane, text="candy-1", command=lambda s=self: candy1(s), | b = Button(cpane, text="bounce", command=lambda s=self: bounce(s), | def __init__(self, framebuffer=1, gui=1): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. ... |
b = Button(cpane, text="candy-2", command=lambda s=self: candy2(s), | b = Button(cpane, text="slideshow", command=lambda s=self: slideshow(s), | def __init__(self, framebuffer=1, gui=1): """ Initialize a PypeApp instance, with side effects :: 1. FrameBuffer instance is created, which means the hardware screen will be opened automatically. Right now, PypeApp guesses about the size & depth of the display to simplify things for the user. This could change. 2. ... |
def candy1(app): | def bounce(app): | def candy1(app): if app.running: return if not app.tk: raise GuiOnlyFunction, 'candy' # cancel candy if it's running.. if app._candy: app.led(0) app._startbut.config(state=NORMAL) app._startbut_tmp.config(state=NORMAL) app._candy = 0 app.udpy_note('') return else: app.led(1) app._startbut.config(state=DISABLED) app.... |
def candy2(app): | def slideshow(app): | def candy2(app): if app.running: return if not app.tk: raise GuiOnlyFunction, 'candy' # cancel candy if it's running.. if app._candy: app.led(0) app._startbut.config(state=NORMAL) app._startbut_tmp.config(state=NORMAL) app._candy = 0 app.udpy_note('') return else: app.led(1) app._startbut.config(state=DISABLED) app.... |
bg.noise(0.50) | if app.sub_common.queryv('show_noise'): bg.noise(0.50) | def candy2(app): if app.running: return if not app.tk: raise GuiOnlyFunction, 'candy' # cancel candy if it's running.. if app._candy: app.led(0) app._startbut.config(state=NORMAL) app._startbut_tmp.config(state=NORMAL) app._candy = 0 app.udpy_note('') return else: app.led(1) app._startbut.config(state=DISABLED) app.... |
except ValueError: | except: | def is_list(s, evaluate=None): """ entry must be a list/vector """ try: v = string.split(s, ':') if len(v) > 1: if s[0] == '=': inc = 1 v = map(int, string.split(s[1:], ':')) else: v = map(int, string.split(s, ':')) inc = 0 if len(v) < 3: stride = 1 else: stride = v[2] r = VALID if inc: val = range(v[0], v[1]+1, stri... |
pype.keyboard() | def runlock(self, lock=1): for slot in self._table: (name, default, validate, descr, runlock) = _unpack_slot(slot) if default: e = self._entries[name].component('entry') if runlock == 1: if lock: e.configure(bg='lightblue') e.configure(state=DISABLED) else: e.configure(bg='white') e.configure(state=NORMAL) | |
if ((self.x-x)**2 + (self.y-y)**2) < size2: | if ((self.x-x)**2 + (self.y-y)**2) < self.size2: | def inside(self, t=None, x=None, y=None): """ If you have multiple landing zones, you can sit in a loop, use app.eye_txy() to query time and eye position ONCE, and then apply it to multiple landing zones by passing in (x,y) values """ if t is None: (t, x, y) = self.app.eye_txy() if ((self.x-x)**2 + (self.y-y)**2) < siz... |
if (t - self.entered_at) >= fixtime: | if (t - self.entered_at) >= self.fixtime: | def inside(self, t=None, x=None, y=None): """ If you have multiple landing zones, you can sit in a loop, use app.eye_txy() to query time and eye position ONCE, and then apply it to multiple landing zones by passing in (x,y) values """ if t is None: (t, x, y) = self.app.eye_txy() if ((self.x-x)**2 + (self.y-y)**2) < siz... |
if (t - self.entered_at) >= fixtime: | if (t - self.entered_at) >= self.fixtime: | def inside(self, t=None, x=None, y=None): """ If you have multiple landing zones, you can sit in a loop, use app.eye_txy() to query time and eye position ONCE, and then apply it to multiple landing zones by passing in (x,y) values """ if t is None: (t, x, y) = self.app.eye_txy() |
self.alpha = pygame.surfarray.pixels_alpha(self.im) | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... | |
self.im.unlock() | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... | |
self.array = pygame.surfarray.pixels3d(self.im) | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... | |
self.im.unlock() | self.array = _SurfArrayAccess(im=self.im, get=pygame.surfarray.array3d, set=pygame.surfarray.pixels3d) self.alpha = _SurfArrayAccess(im=self.im, get=pygame.surfarray.array_alpha, set=pygame.surfarray.pixels_alpha) | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... |
n = uniform(1, 255, shape=shape(self.alpha)) else: n = where(greater(uniform(0, 1, shape=shape(self.alpha)), thresh), 255, 1) | n = uniform(1, 255, shape=shape(self.alpha[:])) else: n = where(greater(uniform(0, 1, shape=shape(self.alpha[:])), thresh), 255, 1) | def noise(self, thresh=0.5): """Fill sprite with noise Fill sprite with binary white noise. Threshold can be used to specified the DC level of the noise. **thresh** -- threshold value [0-1] for binarizing the noise signal. Default's to 0.5 (half black/half white) **returns** -- None """ from RandomArray import unifo... |
self.alpha = pygame.surfarray.pixels_alpha(self.im) self.im.unlock() self.array = pygame.surfarray.pixels3d(self.im) self.im.unlock() | def axisflip(self, xaxis, yaxis): """flip sprite data around axes Flip image on x-axis or y-axis, whatever's true. Uses pygame.transform primitives, so it's fast. | |
self.alpha = pygame.surfarray.pixels_alpha(self.im) self.im.unlock() self.array = pygame.surfarray.pixels3d(self.im) self.im.unlock() | def rotate(self, angle, preserve_size=1, trim=0): """Lossy rotation of spite image data Rotate sprite image about the sprite's center. Uses pygame.transform primitives. | |
self.alpha = pygame.surfarray.pixels_alpha(self.im) self.im.unlock() | def scale(self, new_width, new_height): """Resize this sprite (fast). Resize a sprite using pygame/rotozoom to a new size. Can scale up or down equally well. Changes the data within the sprite, so it's not really invertable. If you want to save the original image data, first clone() and then scale(). | |
self.array = pygame.surfarray.pixels3d(self.im) self.im.unlock() | def scale(self, new_width, new_height): """Resize this sprite (fast). Resize a sprite using pygame/rotozoom to a new size. Can scale up or down equally well. Changes the data within the sprite, so it's not really invertable. If you want to save the original image data, first clone() and then scale(). | |
i = pygame.surfarray.pixels3d(self.im) | def alpha_gradient2(self, r1, r2, bg, x=0, y=0): """Linear gradient vignette Similar to alpha_gradient() method. But the mask is applied *directly to the image data* (under the assumption that the background is a solid fill pattern with color 'bg'). | |
i[:] = ((alpha * i.astype(Float)) + | self.array[:] = ((alpha * i.astype(Float)) + | def alpha_gradient2(self, r1, r2, bg, x=0, y=0): """Linear gradient vignette Similar to alpha_gradient() method. But the mask is applied *directly to the image data* (under the assumption that the background is a solid fill pattern with color 'bg'). |
x = self.X(x) + (w/2) y = self.Y(y) + (h/2) | x = self.X(x) - (w/2) y = self.Y(y) - (h/2) | def subimage(self, x, y, w, h, center=None): """Extract a sub-region Generates a **new** sprite from the specified sub-region of current sprite. |
def __init__(self, sprite, get, set): self.sprite = sprite self.get = get self.set = set | def __init__(self, im, get, set): self.im = im self.getfn = get self.setfn = set def refresh(self, im): """ Underlying sprite array has changed -- update link/cache. This is for when the sprite is resized or rescaled, etc """ self.im = im | def __init__(self, sprite, get, set): self.sprite = sprite self.get = get self.set = set |
array = self.get(self.sprite.im) | array = self.getfn(self.im) | def __getitem__(self, idx): array = self.get(self.sprite.im) return array[idx] |
array = self.set(self.sprite.im) | array = self.setfn(self.im) | def __setitem__(self, idx, value): array = self.set(self.sprite.im) if type(value) is arraytype: array[idx] = value.astype(array.typecode()) else: array[idx] = value |
self.old_array = pygame.surfarray.pixels3d(self.im) | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... | |
self.array = _SurfArrayAccess(sprite=self, | self.array = _SurfArrayAccess(self.im, | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... |
self.alpha = _SurfArrayAccess(sprite=self, | self.alpha = _SurfArrayAccess(self.im, | def __init__(self, width=100, height=100, x=0, y=0, depth=0, \ fb=None, on=1, image=None, dx=0, dy=0, fname=None, \ name=None, icolor='black', centerorigin=0): """Sprite instantiation function **width, height** -- width and height of sprite in pixels **x, y** -- initial sprite position (pixels in world coordinates) ... |
if os.access(fname, os.W_OK): | if not posixpath.exists(fname): try: open(fname, 'w').close() os.unlink(fname) return (fname, 1) except IOError: return (fname, 0) elif os.access(fname, os.W_OK): | def _statefile(self, accesscheck=None): hostname = gethostname() fname = subjectrc('pypestate.%s' % hostname) if accesscheck: if os.access(fname, os.W_OK): return (fname, 1) else: return (fname, 0) else: return fname |
loc = self.stripCommonPrefix(loc, self._relLoc) | loc = posixpath.join(self._relRoot, loc) | def relDstPathOf(self, loc): |
return (mk_script(mailscript) + mailimg + mk_script(mk_line("</a>"))) | result = (mk_script(mailscript) + mailimg + mk_script(mk_line("</a>"))) return result | def cmd(s): print "[shell cmd] %s" % s n = os.system(s) if n != 0: raise Exception("shell cmd error: %s" % n) |
os.chmod(imgfile, mod) os.chown(imgfile, -1, gid) | try: os.chmod(imgfile, mod) except OSError: pass try: os.chown(imgfile, -1, gid) except OSError: pass | def cmd(s): print "[shell cmd] %s" % s n = os.system(s) if n != 0: raise Exception("shell cmd error: %s" % n) |
loc = self.absDstPathOf(loc) loc = self.stripCommonPrefix(loc, self._dstRoot) loc = posixpath.join(self._relRoot, loc) return loc | if loc.startswith("http:") or loc.startswith("https:"): return loc else: loc = self.absDstPathOf(loc) loc = self.stripCommonPrefix(loc, self._dstRoot) loc = posixpath.join(self._relRoot, loc) return loc | def relDstPathOf(self, loc): |
def __init__(self, dtd, filename, mails, encs): | def __init__(self, dtd, mails, enc): | def __init__(self, dtd, filename, mails, encs): |
self.filename = filename | def __init__(self, dtd, filename, mails, encs): | |
self.encs = encs | self.enc = enc | def __init__(self, dtd, filename, mails, encs): |
self.encs[self.filename] = content[19:] | self.enc = content[19:] | def startElement(self, name, attrs): |
raise Exception("In '%s', inconsistent mail address: '%s' vs. '%s'" % (self.filename, self.currentContent(), baremail)) self.mails[(self.filename, self.pending_mail)] = True | raise Exception("Inconsistent mail address: '%s' vs. '%s'" % (self.currentContent(), baremail)) self.mails[self.pending_mail] = True | def endElement(self, name): |
def __init__(self, out, dtd, filename, encoding, mails): | def __init__(self, out, dtd, encoding, mails): | def __init__(self, out, dtd, filename, encoding, mails): |
self.filename = filename | def __init__(self, out, dtd, filename, encoding, mails): | |
self._out.write(self.mails[(self.filename, self.pending_mail)]) | self._out.write(self.mails[self.pending_mail]) | def endElement(self, name): |
usage = '%prog [options] htmlfiles*', | usage = '%prog [options] htmlfile', | def main(): # parse command line cmdlineparser = optparse.OptionParser( usage = '%prog [options] htmlfiles*', conflict_handler = "error", description = '''Protecting mail adresses in html files by obfuscating''', add_help_option = True, ) cmdlineparser.add_option("-t", "--dtd", action="store", dest="dtd", type="string... |
options, filenames = cmdlineparser.parse_args(sys.argv[1:]) | options, (filename,) = cmdlineparser.parse_args(sys.argv[1:]) | def main(): # parse command line cmdlineparser = optparse.OptionParser( usage = '%prog [options] htmlfiles*', conflict_handler = "error", description = '''Protecting mail adresses in html files by obfuscating''', add_help_option = True, ) cmdlineparser.add_option("-t", "--dtd", action="store", dest="dtd", type="string... |
encs = {} for filename in filenames: istream = open(filename, 'r') findhandler = FindHandler(options.dtd, filename, mails, encs) parseWithER(istream, findhandler) istream.close() | enc = outputEncoding istream = open(filename, 'r') findhandler = FindHandler(options.dtd, mails, enc) parseWithER(istream, findhandler) enc = findhandler.enc istream.close() | def main(): # parse command line cmdlineparser = optparse.OptionParser( usage = '%prog [options] htmlfiles*', conflict_handler = "error", description = '''Protecting mail adresses in html files by obfuscating''', add_help_option = True, ) cmdlineparser.add_option("-t", "--dtd", action="store", dest="dtd", type="string... |
mails_subst = {} filenames = {} for filename, mail in mails.iterkeys(): filenames[filename] = True mails_subst[(filename, mail)] = obfuscate(mail, filename) for filename in filenames.iterkeys(): | if mails: mails_subst = {} for mail in mails.iterkeys(): mails_subst[mail] = obfuscate(mail, filename) | def main(): # parse command line cmdlineparser = optparse.OptionParser( usage = '%prog [options] htmlfiles*', conflict_handler = "error", description = '''Protecting mail adresses in html files by obfuscating''', add_help_option = True, ) cmdlineparser.add_option("-t", "--dtd", action="store", dest="dtd", type="string... |
print "writing %s with %s" % (filename, encs.get(filename, outputEncoding)) replacehandler = ReplaceHandler(ostream, options.dtd, filename, encs.get(filename, outputEncoding), mails_subst) | print "writing %s with %s" % (filename, enc) replacehandler = ReplaceHandler(ostream, options.dtd, enc, mails_subst) | def main(): # parse command line cmdlineparser = optparse.OptionParser( usage = '%prog [options] htmlfiles*', conflict_handler = "error", description = '''Protecting mail adresses in html files by obfuscating''', add_help_option = True, ) cmdlineparser.add_option("-t", "--dtd", action="store", dest="dtd", type="string... |
print >> omap, "struct pair_encodemap jisx0213_pairencmap" \ | print >> omap, "struct pair_encodemap jisx0213_pair_encmap" \ | def loadmap_jisx0213(fo): decmap3, decmap4 = {}, {} # maps to BMP for level 3 and 4 decmap3_2, decmap4_2 = {}, {} # maps to U+2xxxx for level 3 and 4 decmap3_pair = {} # maps to BMP-pair for level 3 for line in fo: line = line.split('#', 1)[0].strip() if not line or len(line.split()) < 2: continue row = line.split() l... |
self.window.set_title('%d%% - %s' % (100. * sumfile.vbytes / tbytes, os.path.basename(sumfile.filename))) | s = '%d%%' % (100. * sumfile.vbytes / tbytes) if sumfile.filename: s += ' - ' + os.path.basename(sumfile.filename) self.window.set_title(s) | def show_all_progress(self, sumfile, tfiles, tbytes): self.show_progress(self.progress_files, sumfile.vfiles / tfiles) self.show_progress(self.progress_bytes, sumfile.vbytes / tbytes) self.window.set_title('%d%% - %s' % (100. * sumfile.vbytes / tbytes, os.path.basename(sumfile.filename))) |
os.remove(options.outfilename) | try: os.remove(options.outfilename) except OSError: pass | def main(): platform_win32 = sys.platform.startswith("win") if platform_win32: usage = """ |
if ((type == fonttype) and (type != name)): | if ((type == fonttype) and (beautify(type) != name)): | def listFontNamesForType(self, fonttype): """return sorted list of all known font names for a font type """ nameList = [] for name, type in FontData.fontNames.iteritems(): if ((type == fonttype) and (type != name)): nameList.append(name) nameList.sort() return nameList |
widget = GUIobj.getChatWindow() | widget = GUIobj.chat_window | def doScroll(event,GUIobj,*args): """ make the scroll scrolling :) """ widget = GUIobj.getChatWindow() op, howMany = args[0], args[1] if op == "scroll": units = args[2] widget.yview_scroll ( howMany, units ) elif op == "moveto": widget.yview_moveto ( howMany ) |
raise TypeError("Non-string name detected: %s" %name.__class__.__name__) | raise TypeError("Non-string name detected: %s" %n.__class__.__name__) | def enumvals(names, incfunc): #{{{ inc = incfunc() nfunc, cfunc = inc.next, inc.send for n in names: #{{{ if isinstance(n, tuple): name, val = n if not isinstance(name, basestring): raise TypeError("Non-string name detected: %s" %name.__class__.__name__) elif not isinstance(val, int) and not isinstance(val, long): rais... |
assert hasattr(suite, '__path__') | assert hasattr(obj, '__path__') | def isdirmodule(obj): try: assert hasattr(suite, '__path__') assert ismodule(obj) except: return False return True |
assert isinstance(text, str) | assert isinstance(text, (str, unicode)) | def write(self, text): assert isinstance(text, str) if text.startswith(self._error_start): errend = text.find('-->') if errend >= 0: text = text[errend + 4:] if self._text != text: self._text = text # XXX can this be done only if we changed self._text? self._cook() |
"""Returns the TALES expression | """Returns the TALES expression evaluator. | def pt_getEngine(): """Returns the TALES expression """ |
pt_render(namespace, source=0) | pt_render(namespace, source=False, sourceAnnotations=False) | def __get__(self, parent, type=None): parent._cook_check() return parent._v_macros |
def pt_render(self, namespace, source=False): | def pt_render(self, namespace, source=False, sourceAnnotations=False): | def pt_render(self, namespace, source=False): """Render this Page Template""" self._cook_check() __traceback_supplement__ = (PageTemplateTracebackSupplement, self, namespace) if self._v_errors: raise PTRuntimeError(str(self._v_errors)) |
context, output, tal=not source, strictinsert=0)() | context, output, tal=not source, strictinsert=0, sourceAnnotations=sourceAnnotations)() | def pt_render(self, namespace, source=False): """Render this Page Template""" self._cook_check() __traceback_supplement__ = (PageTemplateTracebackSupplement, self, namespace) if self._v_errors: raise PTRuntimeError(str(self._v_errors)) |
zope.interface.implements( zope.pagetemplate.interfaces.IPageTemplateSubclassing) | implements(IPageTemplateSubclassing) | def __get__(self, parent, type=None): parent._cook_check() return parent._v_macros |
macros = MacroCollection() | def macros(self): self._cook_check() return self._v_macros macros = property(macros) | def __get__(self, parent, type=None): parent._cook_check() return parent._v_macros |
pt_render(namespace, source=False, sourceAnnotations=False) | pt_render(namespace, source=False, sourceAnnotations=False, showtal=False) | def __get__(self, parent, type=None): parent._cook_check() return parent._v_macros |
def pt_render(self, namespace, source=False, sourceAnnotations=False): | def pt_render(self, namespace, source=False, sourceAnnotations=False, showtal=False): | def pt_render(self, namespace, source=False, sourceAnnotations=False): """Render this Page Template""" self._cook_check() __traceback_supplement__ = (PageTemplateTracebackSupplement, self, namespace) if self._v_errors: raise PTRuntimeError(str(self._v_errors)) |
context, output, tal=not source, strictinsert=0, sourceAnnotations=sourceAnnotations)() | context, output, tal=not source, showtal=showtal, strictinsert=0, sourceAnnotations=sourceAnnotations)() | def pt_render(self, namespace, source=False, sourceAnnotations=False): """Render this Page Template""" self._cook_check() __traceback_supplement__ = (PageTemplateTracebackSupplement, self, namespace) if self._v_errors: raise PTRuntimeError(str(self._v_errors)) |
logging.error('PageTemplateFile: Error in template: %s', '\n'.join(self._v_errors)) | logging.error('PageTemplateFile: Error in template %s: %s', self.filename, '\n'.join(self._v_errors)) | def _cook_check(self): if self._v_last_read and not __debug__: return __traceback_info__ = self.filename try: mtime = os.path.getmtime(self.filename) except OSError: mtime = 0 if self._v_program is not None and mtime == self._v_last_read: return text, type_ = self._read_file() self.pt_edit(text, type_) self._cook() if ... |
def read(self): | def read(self, request=None): | def read(self): """Gets the source, sometimes with macros expanded.""" self._cook_check() if not self._v_errors: if not self.expand: return self._text try: # This gets called, if macro expansion is turned on. # Note that an empty dictionary is fine for the context at # this point, since we are not evaluating the templa... |
return self.pt_render(self.pt_getContext(self, None), source=1) | return self.pt_render(self.pt_getContext(self, request), source=1) | def read(self): """Gets the source, sometimes with macros expanded.""" self._cook_check() if not self._v_errors: if not self.expand: return self._text try: # This gets called, if macro expansion is turned on. # Note that an empty dictionary is fine for the context at # this point, since we are not evaluating the templa... |
def _test_on_error_in_slot_filler(self): | def test_on_error_in_slot_filler(self): | def _test_on_error_in_slot_filler(self): # The here/xxx isn't defined, so the macro definition is # expected to catch the error that gets raised. text = '''\ <div metal:define-macro="foo"> <div tal:on-error="string:eek"> <div metal:define-slot="slot" /> cool </div> </div> |
return self.pt_render({}, source=1) | return self.pt_render(self.pt_getContext(self, None), source=1) | def read(self): """Gets the source, sometimes with macros expanded.""" self._cook_check() if not self._v_errors: if not self.expand: return self._text try: # This gets called, if macro expansion is turned on. # Note that an empty dictionary is fine for the context at # this point, since we are not evaluating the templa... |
grassEnv = grass.GRASS(self.grassSettings) try: self.mapset = grassEnv.mkmapset(self.process.grassLocation) self.dirsToRemove.append(os.path.join(self.process.grassLocation,self.mapset)) self.process.grassenv=grassEnv.grassenv except AttributeError: self.mapset = grassEnv.mkmapset() | def execute(self): """ 1) Creates the temporary directory 2) If needed, downloads the data 3) Calls the process 4) Returns the XML or the resulting file/value 5) Cleans the temporary directory |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.