rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if flags&records: | if flags&RECORDS: | def __init__(self, stdin, environ, response, clean=0, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile( ':[a-zA-Z][a-zA-Z0-9_]+$' ).search, rfi... |
positions = v[1] + value[1] | positions = map(None, v[1] + value[1]) | def near(self, x, distance = 1): '''\ near(rl, distance = 1) Returns a ResultList containing documents which contain''' result = self.__class__() for key, v in self.items(): try: value = x[key] except KeyError: value = None if value is None: continue |
val = md[name] | if have_arg('url'): val=md.getitem(name,0) val=val.absolute_url() else: val = md[name] | def render(self, md): args=self.args have_arg=args.has_key name=self.__name__ |
raise KeyError | raise KeyError, name | def render(self, md): args=self.args have_arg=args.has_key name=self.__name__ |
if have_arg('url'): val=val.absolute_url() | def render(self, md): args=self.args have_arg=args.has_key name=self.__name__ | |
elif module[-4:]=='.py': module=module[:-4] | elif module[-4:]=='.pyc': module=module[:-4] | def manage_edit(self, title, module, function, REQUEST=None): """Change the external method |
def redirect(self, location, status=302): | def redirect(self, location, status=302, lock=0): | def redirect(self, location, status=302): """Cause a redirection without raising an error""" self.setStatus(status) self.setHeader('Location', location) |
self._locked_status = 1 | if lock: self._locked_status = 1 | def redirect(self, location, status=302): """Cause a redirection without raising an error""" self.setStatus(status) self.setHeader('Location', location) |
manage_options=Folder.manage_options+( {'label':'Distribution', 'action':'manage_distributionView'}, ) | manage_options=( {'label':'Contents', 'action':'manage_main'}, {'label':'Properties', 'action':'manage_propertiesForm'}, {'label':'Security', 'action':'manage_access'}, {'label':'Undo', 'action':'manage_UndoForm'}, {'label':'Find', 'action':'manage_findFrame'}, {'label':'Distribution', 'action':'manage_distributionView... | def new_version(self, _intending=regex.compile("[.]?[0-9]+$").search, ): # Return a new version number based on the existing version. v=str(self.version) if not v: return '1.0' if _intending(v) < 0: return v l=rfind(v,'.') return v[:l+1]+str(1+atoi(v[l+1:])) |
def manage_addPropertySheet(self, id, ns): | def manage_addPropertySheet(self, id, ns, REQUEST=None): | def manage_addPropertySheet(self, id, ns): """ """ md={'xmlns':ns} ps=PropertySheet(id, md) self.addPropertySheet(ps) return 'OK' |
ps=PropertySheet(id, md) | ps= self.PropertySheetClass(id, md) | def manage_addPropertySheet(self, id, ns): """ """ md={'xmlns':ns} ps=PropertySheet(id, md) self.addPropertySheet(ps) return 'OK' |
return 'OK' | if REQUEST is None: return ps ps= self.get(id) REQUEST.RESPONSE.redirect('%s/manage' % ps.absolute_url()) | def manage_addPropertySheet(self, id, ns): """ """ md={'xmlns':ns} ps=PropertySheet(id, md) self.addPropertySheet(ps) return 'OK' |
pre=r['URL'] | pre=r['URLPATH0'] | def manage_options(self): """Return a manage option data structure for me instance """ try: r=self.REQUEST except: r=None if r is None: pre='../' else: pre=r['URL'] for i in (1,2): l=pre.rfind('/') if l >= 0: pre=pre[:l] pre=pre+'/' |
def test_dont_break_getPhysicalPath(self): item = SimpleItem() self.assertEqual(item.getPhysicalPath(), ('',)) self.assertEqual(item.getPhysicalPath(), makerequest(item).getPhysicalPath()) | def test_dont_break_getPhysicalPath(self): # see http://www.zope.org/Collectors/Zope/2057 item = SimpleItem() self.assertEqual(item.getPhysicalPath(), ('',)) self.assertEqual(item.getPhysicalPath(), makerequest(item).getPhysicalPath()) | |
self.conn.send("helo "+localHost+"\r\n") | self.conn.send("helo "+localHost+"\015\012") | def __init__(self, smtpHost, smtpPort, localHost="localhost", timeout=1): self.conn = socket(AF_INET, SOCK_STREAM) self.conn.connect(smtpHost, smtpPort) self.timeout=timeout self.fd=self.conn.fileno() self.conn.send("helo "+localHost+"\r\n") while 1: if not self._check(): break |
if code > 500: | if code > 400: | def _check(self, lev='250'): line = self.getLine() if not line: return 0 #can't check an empty line, eh? try: code=string.atoi(line[:3]) except: raise smtpError, "Cannot convert line from SMTP: %s" % line |
self.conn.send("mail from:<%s>\n" % mfrom) | self.conn.send("mail from:<%s>\015\012" % mfrom) | def send(self, mfrom, mto, subj='No Subject', body='Blank Message'): self.conn.send("mail from:<%s>\n" % mfrom) self._check() if type(mto) in [types.ListType, types.TupleType]: for person in mto: self.conn.send("rcpt to:<%s>\n" % person) self._check() else: self.conn.send("rcpt to:<%s>\n" % mto) self._check() self.conn... |
self.conn.send("rcpt to:<%s>\n" % person) | self.conn.send("rcpt to:<%s>\015\012" % person) | def send(self, mfrom, mto, subj='No Subject', body='Blank Message'): self.conn.send("mail from:<%s>\n" % mfrom) self._check() if type(mto) in [types.ListType, types.TupleType]: for person in mto: self.conn.send("rcpt to:<%s>\n" % person) self._check() else: self.conn.send("rcpt to:<%s>\n" % mto) self._check() self.conn... |
self.conn.send("rcpt to:<%s>\n" % mto) | self.conn.send("rcpt to:<%s>\015\012" % mto) | def send(self, mfrom, mto, subj='No Subject', body='Blank Message'): self.conn.send("mail from:<%s>\n" % mfrom) self._check() if type(mto) in [types.ListType, types.TupleType]: for person in mto: self.conn.send("rcpt to:<%s>\n" % person) self._check() else: self.conn.send("rcpt to:<%s>\n" % mto) self._check() self.conn... |
self.conn.send("data\n") | self.conn.send("data\015\012") | def send(self, mfrom, mto, subj='No Subject', body='Blank Message'): self.conn.send("mail from:<%s>\n" % mfrom) self._check() if type(mto) in [types.ListType, types.TupleType]: for person in mto: self.conn.send("rcpt to:<%s>\n" % person) self._check() else: self.conn.send("rcpt to:<%s>\n" % mto) self._check() self.conn... |
self.conn.send("\n.\n") | self.conn.send("\015\012.\015\012") | def send(self, mfrom, mto, subj='No Subject', body='Blank Message'): self.conn.send("mail from:<%s>\n" % mfrom) self._check() if type(mto) in [types.ListType, types.TupleType]: for person in mto: self.conn.send("rcpt to:<%s>\n" % person) self._check() else: self.conn.send("rcpt to:<%s>\n" % mto) self._check() self.conn... |
self.conn.send("quit\n") | self.conn.send("quit\015\012") | def _close(self): self.conn.send("quit\n") self.conn.close() |
opts, args = getopt.getopt(sys.argv[1:], 'p:u:v9') | opts, args = getopt.getopt(sys.argv[1:], 'p:u:DIv9') | def main(): user, password = 'superuser', '123' opts, args = getopt.getopt(sys.argv[1:], 'p:u:v9') global verbose global old for o, v in opts: if o=='-p': d, f = os.path.split(v) if f=='ZPublisher': sys.path.insert(0,d) else: sys.path.insert(0,v) elif o=='-u': v = string.split(v,':') user, password = v[0], string.join(... |
call(object.manage_addFile, id=name, file=open(f)) | call(object.manage_addFile, id=name, file=open(f,'rb')) | def upload_file(object, f): if os.path.isdir(f): return upload_dir(object, f) dir, name = os.path.split(f) root, ext = os.path.splitext(name) if ext in ('file', 'dir'): ext='' else: ext=string.lower(ext) if ext and ext[0] in '.': ext=ext[1:] if ext and globals().has_key('upload_'+ext): if verbose: print 'upload_'+ext, ... |
title, head, body = parse_html(f) | if doctor: title, head, body = parse_html(f) else: if old: f=f.read() title, head, body = '', '', f | def upload_html(object, f): dir, name = os.path.split(f) f=open(f) # There is a Document bugs that causes file uploads to fail. # Waaa. This will be fixed in 1.10.2. #f=f.read() title, head, body = parse_html(f) if old: call(object.manage_addDocument, id=name, file=body) else: call(object.manage_addDTMLDocument, id=... |
call(object.manage_addDocument, id=name, file=open(f)) | f=f.read() call(object.manage_addDocument, id=name, file=f) | def upload_dtml(object, f): dir, name = os.path.split(f) if old: call(object.manage_addDocument, id=name, file=open(f)) else: call(object.manage_addDTMLDocument, id=name, file=f) |
call(object.manage_addDTMLDocument, id=name, file=f) | call(object.manage_addDTMLMethod, id=name, file=f) | def upload_dtml(object, f): dir, name = os.path.split(f) if old: call(object.manage_addDocument, id=name, file=open(f)) else: call(object.manage_addDTMLDocument, id=name, file=f) |
call(object.manage_addImage, id=name, file=open(f)) | call(object.manage_addImage, id=name, file=open(f,'rb')) | def upload_gif(object, f): dir, name = os.path.split(f) call(object.manage_addImage, id=name, file=open(f)) |
d['rand']=math d['whrand']=math | d['rand']=rand d['whrand']=whrand | def careful_getslice(md, seq, *indexes): v=len(indexes) if v==2: v=seq[indexes[0]:indexes[1]] elif v==1: v=seq[indexes[0]:] else: v=seq[:] if type(seq) is type(''): return v # Short-circuit common case validate=md.validate if validate is not None: for e in v: if not validate(seq,seq,'',e,md): raise ValidationError, '... |
query=self.template(self,argdata) | query=apply(self.template, (self,), argdata) | def __call__(self,REQUEST=None): |
self.__name__=args or tname | self.__name__="%s %s" % (tname, args) args = parse_params(args, required=1) self.args=args if args.has_key('required'): self.required=args['required'] elif args.has_key('') and args['']=='required': self.required=1 | def __init__(self, blocks): |
product.manage_options=OFS.Folder.Folder.manage_options | product.manage_options=Folder.manage_options | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=get... |
self.report(join( traceback.format_tb(tb_tb)) + '\n') | self.report(string.join(traceback.format_tb(tb_tb)) + '\n') | def getSuiteFromFile(self, filepath): if not os.path.isfile(filepath): raise ValueError, '%s is not a file' % filepath path, filename=os.path.split(filepath) name, ext=os.path.splitext(filename) file, pathname, desc=imp.find_module(name, [path]) saved_syspath = sys.path[:] try: sys.path.append(path) # let module ... |
def custom_default_report(id, result, action='', no_table=0): | def custom_default_report(id, result, action='', no_table=0, goofy=regex.compile('[^a-zA-Z0-9_]').search ): | def custom_default_report(id, result, action='', no_table=0): columns=result._searchable_result_columns() __traceback_info__=columns heading=('<tr>\n%s\t</tr>' % string.joinfields( map(lambda c: '\t<th>%s</th>\n' % nicify(c['name']), columns), '' ) ) if no_table: tr, _tr, td, _td, delim = '<p>', '</p>', '', '', ', ' e... |
row=('%s\n%s\t%s' % (tr,string.joinfields( map(lambda c, td=td, _td=_td: '\t%s<!-- % (td,urllib.quote(c['name']), c['type']!='s' and ' null=""' or '',_td), columns), delim), _tr)) | row=[] for c in columns: n=c['name'] if goofy(n) >= 0: n='expr="_vars[\'%s]"' % (`'"'+n`[2:]) row.append('\t%s<!-- % (td,n,c['type']!='s' and ' null=""' or '',_td)) row=('%s\n%s\t%s' % (tr,string.joinfields(row,delim), _tr)) | def custom_default_report(id, result, action='', no_table=0): columns=result._searchable_result_columns() __traceback_info__=columns heading=('<tr>\n%s\t</tr>' % string.joinfields( map(lambda c: '\t<th>%s</th>\n' % nicify(c['name']), columns), '' ) ) if no_table: tr, _tr, td, _td, delim = '<p>', '</p>', '', '', ', ' e... |
if not ifhdr: RESPONSE.setStatus(412) | if not ifhdr: raise 'Precondition Failed', 'If Header Missing' | def LOCK(self, REQUEST, RESPONSE): """Lock a resource""" self.dav__init(REQUEST, RESPONSE) security = getSecurityManager() creator = security.getUser() body = REQUEST.get('BODY', '') ifhdr = REQUEST.get_header('If', None) depth = REQUEST.get_header('Depth', 'infinite') alreadylocked = Lockable.wl_isLocked(self) |
raise SyntaxError, "sort oder must be either ASC or DESC" | raise SyntaxError, "sort direction must be either ASC or DESC" | def make_sortfunctions(sortfields, _): """Accepts a list of sort fields; splits every field, finds comparison function. Returns a list of 3-tuples (field, cmp_function, asc_multplier)""" sf_list = [] for field in sortfields: f = list(field) l = len(f) if l == 1: f.append("cmp") f.append("asc") elif l == 2: f.append("... |
Cache._setPropValue(self, id, value) | PropertyManager._setPropValue(self, id, value) | def _setPropValue(self, id, value): Cache._setPropValue(self, id, value) self.ZCacheable_invalidate() |
r.append(name, value) | r.append((name, value)) | def parse_qsl(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. Arguments: qs: URL-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value inicates that blanks should be re... |
'cst':'Us/Central','cuba':'Cuba','est':'US/Eastern','egypt':'Egypt', | 'cst':'US/Central','cuba':'Cuba','est':'US/Eastern','egypt':'Egypt', | def info(self,t=None): idx=self.index(t)[0] zs =self.az[self.tinfo[idx][2]:] return self.tinfo[idx][0],self.tinfo[idx][1],zs[:find(zs,'\000')] |
def _findLocalTimeZoneName(isDST): if not daylight: isDST = 0 try: _localzone = _cache._zmap[lower(tzname[isDST])] except: try: _localzone = _cache._zmap[lower(tzname[0])] except: try: if isDST: localzone = altzone else: localzone = timezone offset=(-localzone/(60*60)) majorOffset=int(offset) if majorOffset != 0 ... | def __getitem__(self,k): try: n=self._zmap[lower(k)] except KeyError: if numericTimeZoneMatch(k) <= 0: raise 'DateTimeError','Unrecognized timezone: %s' % k return k try: return self._d[n] except KeyError: z=self._d[n]=_timezone(self._db[n]) return z | |
t,tz=time(),self._localzone ms=(t-int(t)) yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6] s=(hr/24.0+mn/1440.0+(sc+ms)/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s yr,mo,dy,hr,mn,sc=localtime(t)[:6] | t = time() lt = safelocaltime(t) tz = self.localZone(lt) ms = (t - math.floor(t)) s,d = _calcSD(t) yr,mo,dy,hr,mn,sc=lt[:6] | def __init__(self,*args): """Return a new date-time object |
ms=(t-int(t)) yr,mo,dy,hr,mn,sc=gmtime(t)[:6] s=(hr/24.0+mn/1440.0+(sc+ms)/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s x=d+(self._tzinfo[tz].info(t)[0]/86400.0) yr,mo,dy=self._calendarday(x+jd1901) x=(x-int(x))*86400.0 hr=int(x/3600) x=x-(hr*3600) mn=int(x/60) sc=x-(mn*60) | ms=(t-math.floor(t)) s,d = _calcSD(t) x = _calcDependentSecond(tz, t) yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, ms) | def __init__(self,*args): """Return a new date-time object |
try: tz=self._tzinfo._zmap[lower(tz)] except KeyError: if numericTimeZoneMatch(tz) <= 0: raise self.DateTimeError, 'Invalid date: %s' % arg | def __init__(self,*args): """Return a new date-time object | |
s=(hr/24.0+mn/1440.0+sc/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s t=(d*86400.0)-EPOCH+86400.0 try: a=self._tzinfo[tz].info(t)[0] except: if numericTimeZoneMatch(tz) > 0: a=atoi(tz[1:3])*3600+atoi(tz[3:5])*60 d,t=d-(a/86400.0),t-a | ms = sc - math.floor(sc) x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc) if tz: try: tz=self._tzinfo._zmap[lower(tz)] except KeyError: if numericTimeZoneMatch(tz) <= 0: raise self.DateTimeError, \ 'Unknown time zone in date: %s' % arg else: tz = self._calcTimezoneName(x, ms) s,d,t,millisecs = _calcIndependentSecondEtc(tz... | def __init__(self,*args): """Return a new date-time object |
t,tz=arg,self._localzone ms=(t-int(t)) yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6] s=(hr/24.0+mn/1440.0+(sc+ms)/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s yr,mo,dy,hr,mn,sc=localtime(t)[:6] | t = arg lt = safelocaltime(t) tz = self.localZone(lt) ms=(t-math.floor(t)) s,d = _calcSD(t) yr,mo,dy,hr,mn,sc=lt[:6] | def __init__(self,*args): """Return a new date-time object |
ms=(t-int(t)) | ms = (t - math.floor(t)) | def __init__(self,*args): """Return a new date-time object |
yr,mo,dy,hr,mn,sc=gmtime(t)[:6] s=(hr/24.0+mn/1440.0+(sc+ms)/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s x=d+(self._tzinfo[tz].info(t)[0]/86400.0) yr,mo,dy=self._calendarday(x+jd1901) x=(x-int(x))*86400.0 hr=int(x/3600) x=x-(hr*3600) mn=int(x/60) sc=x-(mn*60) if(hr==23 and mn==59 and sc>59.999): hr,mn,sc=0,0,0.0 e... | s,d = _calcSD(t) x = _calcDependentSecond(tz, t) yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, ms) | def __init__(self,*args): """Return a new date-time object |
tz=self._localzone | t = time() lt = safelocaltime(t) tz = self.localZone(lt) | def __init__(self,*args): """Return a new date-time object |
d=(self._julianday(yr,1,0)-jd1901)+jul yr,mo,dy=self._calendarday(d+jd1901) x=(d-int(d))*86400.0 hr=int(x/3600) x=x-(hr*3600) mn=int(x/60) sc=x-(mn*60) if(hr==23 and mn==59 and sc>59.999): hr,mn,sc=0,0,0.0 else: if hr<0: hr=23+hr if mn<0: mn=59+mn if sc<0: if (sc-int(sc)>=0.999): sc=round(sc) sc=59+sc d=d-(self._tzin... | d=(_julianday(yr,1,0)-jd1901)+jul x_float = d * 86400.0 x_floor = math.floor(x_float) ms = x_float - x_floor x = long(x_floor) yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, ms) s,d,t,millisecs = _calcIndependentSecondEtc(tz, x, ms) | def __init__(self,*args): """Return a new date-time object |
if not tz: tz=self._localzone else: tz=self._tzinfo._zmap[lower(tz)] leap=yr%4==0 and (yr%100!=0 or yr%400==0) s=(hr/24.0+mn/1440.0+sc/86400.0) d=(self._julianday(yr,mo,dy)-jd1901)+s t=(d*86400.0)-EPOCH+86400.0 a=self._tzinfo[tz].info(t)[0] d,t=d-(a/86400.0),t-a | leap = (yr % 4 == 0) and (yr % 100 != 0 or yr % 400 == 0) x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc) ms = sc - math.floor(sc) if tz: try: tz=self._tzinfo._zmap[lower(tz)] except KeyError: if numericTimeZoneMatch(tz) <= 0: raise self.DateTimeError, \ 'Unknown time zone: %s' % tz else: tz = self._calcTimezoneName(x, ... | def __init__(self,*args): """Return a new date-time object |
self._dayoffset=dx=int((self._julianday(yr,mo,dy)+2L)%7) | self._dayoffset=dx=int((_julianday(yr,mo,dy)+2L)%7) | def __init__(self,*args): """Return a new date-time object |
if millisecs is None: millisecs = long(math.floor(t * 1000.0)) self._millis = millisecs | def __init__(self,*args): """Return a new date-time object | |
try: _localzone=_cache._zmap[lower(tzname[0])] except: | _localzone0 = _findLocalTimeZoneName(0) _localzone1 = _findLocalTimeZoneName(1) _multipleZones = (_localzone0 != _localzone1) _isDST = localtime(time())[8] _localzone = _isDST and _localzone1 or _localzone0 _tzinfo = _cache() def localZone(self, ltm=None): '''Returns the time zone on the given date. The time z... | def __init__(self,*args): """Return a new date-time object |
t=time() localzone=float(int(mktime(gmtime(t))) - int(t)) offset=(-localzone/(60*60)) majorOffset=int(offset) if majorOffset != 0 : minorOffset=abs(int((offset % majorOffset) * 60.0)) else: minorOffset = 0 m=majorOffset >= 0 and '+' or '' lz='%s%0.02d%0.02d' % (m, majorOffset, minorOffset) _localzone=_cache._zmap[lower... | ltm = safelocaltime(nearTime) except: yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, 0) yr = ((yr - 1970) % 28) + 1970 x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc) nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms ltm = safelocaltime(nearTime) tz = self.localZone(ltm) return tz | def __init__(self,*args): """Return a new date-time object |
sp=split(strip(string)) | string = strip(string) sp=split(string) | def _parse(self,string): # Parse date-time components from a string month=year=tz=tm=None spaces =self.space_chars intpat =self.int_pattern fltpat =self.flt_pattern wordpat =self.name_pattern delimiters =self.delimiters MonthNumbers =self._monthmap DayOfWeekNames=self._daymap ValidZones ... |
else: tz=self._localzone | else: tz = None | def _parse(self,string): # Parse date-time components from a string month=year=tz=tm=None spaces =self.space_chars intpat =self.int_pattern fltpat =self.flt_pattern wordpat =self.name_pattern delimiters =self.delimiters MonthNumbers =self._monthmap DayOfWeekNames=self._daymap ValidZones ... |
if day is None: raise self.SyntaxError, string | if day is None: year,month,day = localtime(time())[:3] | def _parse(self,string): # Parse date-time components from a string month=year=tz=tm=None spaces =self.space_chars intpat =self.int_pattern fltpat =self.flt_pattern wordpat =self.name_pattern delimiters =self.delimiters MonthNumbers =self._monthmap DayOfWeekNames=self._daymap ValidZones ... |
hr=int(t/3600) t=t-hr*3600 mn=int(t/60) sc=t-mn*60 tz=tz or self._localzone | t_int = long(math.floor(t)) hr,mn,sc = _calcHMS(t_int, t - t_int) if not tz: x = _calcDependentSecond2(year,month,day,hr,mn,sc) tz = self._calcTimezoneName(x, t - t_int) | def _parse(self,string): # Parse date-time components from a string month=year=tz=tm=None spaces =self.space_chars intpat =self.int_pattern fltpat =self.flt_pattern wordpat =self.name_pattern delimiters =self.delimiters MonthNumbers =self._monthmap DayOfWeekNames=self._daymap ValidZones ... |
def _julianday(self,yr,mo,dy): y,m,d=long(yr),long(mo),long(dy) if m > 12L: y=y+m/12L m=m%12L elif m < 1L: m=-m y=y-m/12L-1L m=12L-m%12L if y > 0L: yr_correct=0L else: yr_correct=3L if m < 3L: y, m=y-1L,m+12L if y*10000L+m*100L+d > 15821014L: b=2L-y/100L+y/400L else: b=0L return (1461L*y-yr_correct)/4L+306001L*(m+... | def _julianday(self,yr,mo,dy): y,m,d=long(yr),long(mo),long(dy) if m > 12L: y=y+m/12L m=m%12L elif m < 1L: m=-m y=y-m/12L-1L m=12L-m%12L if y > 0L: yr_correct=0L else: yr_correct=3L if m < 3L: y, m=y-1L,m+12L if y*10000L+m*100L+d > 15821014L: b=2L-y/100L+y/400L else: b=0L return (1461L*y-yr_correct)/4L+306001L*(m+... | |
if (t>0 and ((t/86400.0) < 24837)): yr,mo,dy,hr,mn,sc=gmtime(t+self._tzinfo[tz].info(t)[0])[:6] | millis = self.millis() try: yr,mo,dy,hr,mn,sc=safegmtime(t+_tzoffset(tz, t))[:6] | def toZone(self, z): """Return a DateTime with the value as the current object, represented in the indicated timezone.""" t,tz=self._t,self._tzinfo._zmap[lower(z)] if (t>0 and ((t/86400.0) < 24837)): # Try to cheat and use time module for speed... yr,mo,dy,hr,mn,sc=gmtime(t+self._tzinfo[tz].info(t)[0])[:6] sc=self._sec... |
return self.__class__(yr,mo,dy,hr,mn,sc,tz,t,self._d,self.time) d=self._d+(self._tzinfo[tz].info(t)[0]/86400.0) yr,mo,dy=self._calendarday((d+jd1901)) s=(d-int(d))*86400.0 hr=int(s/3600) s=s-(hr*3600) mn=int(s/60) sc=s-(mn*60) if(hr==23 and mn==59 and sc>59.999): hr,mn,sc=0,0,0.0 else: if hr<0: hr=23+hr if mn<0: mn=5... | return self.__class__(yr,mo,dy,hr,mn,sc,tz,t, self._d,self.time,millis) except: tzdiff = _tzoffset(tz, t) - _tzoffset(self._tz, t) if tzdiff == 0: return self sc = self._second ms = sc - math.floor(sc) x = _calcDependentSecond2(self._year, self._month, self._day, self._hour, self._minute, sc) x_new = x + tzdiff yr,mo,... | def toZone(self, z): """Return a DateTime with the value as the current object, represented in the indicated timezone.""" t,tz=self._t,self._tzinfo._zmap[lower(z)] if (t>0 and ((t/86400.0) < 24837)): # Try to cheat and use time module for speed... yr,mo,dy,hr,mn,sc=gmtime(t+self._tzinfo[tz].info(t)[0])[:6] sc=self._sec... |
return gmtime(t+self._tzinfo[self._tz].info(t)[0])[0]==self._year | return safegmtime(t+_tzoffset(self._tz, t))[0]==self._year | def isCurrentYear(self): """Return true if this object represents a date/time that falls within the current year, in the context of this object\'s timezone representation""" t=time() return gmtime(t+self._tzinfo[self._tz].info(t)[0])[0]==self._year |
return gmtime(t+self._tzinfo[self._tz].info(t)[0])[1]==self._month | return safegmtime(t+_tzoffset(self._tz, t))[1]==self._month | def isCurrentMonth(self): """Return true if this object represents a date/time that falls within the current month, in the context of this object\'s timezone representation""" t=time() return gmtime(t+self._tzinfo[self._tz].info(t)[0])[1]==self._month |
return gmtime(t+self._tzinfo[self._tz].info(t)[0])[2]==self._day | return safegmtime(t+_tzoffset(self._tz, t))[2]==self._day | def isCurrentDay(self): """Return true if this object represents a date/time that falls within the current day, in the context of this object\'s timezone representation""" t=time() return gmtime(t+self._tzinfo[self._tz].info(t)[0])[2]==self._day |
return gmtime(t+self._tzinfo[self._tz].info(t)[0])[3]==self._hour | return safegmtime(t+_tzoffset(self._tz, t))[3]==self._hour | def isCurrentHour(self): """Return true if this object represents a date/time that falls within the current hour, in the context of this object\'s timezone representation""" t=time() return gmtime(t+self._tzinfo[self._tz].info(t)[0])[3]==self._hour |
return gmtime(t+self._tzinfo[self._tz].info(t)[0])[4]==self._minute | return safegmtime(t+_tzoffset(self._tz, t))[4]==self._minute | def isCurrentMinute(self): """Return true if this object represents a date/time that falls within the current minute, in the context of this object\'s timezone representation""" t=time() return gmtime(t+self._tzinfo[self._tz].info(t)[0])[4]==self._minute |
or time module style time.""" try: return (self._d > t._d) | or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() > t.millis()) | def greaterThan(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than the specified DateTime or time module style time.""" try: return (self._d > t._d) exc... |
specified DateTime or time module style time.""" try: return (self._d >= t._d) | specified DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() >= t.millis()) | def greaterThanEqualTo(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time greater than or equal to the specified DateTime or time module style time.""" try: return (... |
or time module style time.""" try: return (self._d == t._d) | or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() == t.millis()) | def equalTo(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time equal to the specified DateTime or time module style time.""" try: return (self._d == t._d) except: re... |
or time module style time.""" try: return (self._d != t._d) | or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() != t.millis()) | def notEqualTo(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time not equal to the specified DateTime or time module style time.""" try: return (self._d != t._d) exc... |
or time module style time.""" try: return (self._d < t._d) | or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() < t.millis()) | def lessThan(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than the specified DateTime or time module style time.""" try: return (self._d < t._d) except: r... |
DateTime or time module style time.""" try: return (self._d <= t._d) | DateTime or time module style time. Revised to give more correct results through comparison of long integer milliseconds. """ try: return (self.millis() <= t.millis()) | def lessThanEqualTo(self,t): """Compare this DateTime object to another DateTime object OR a floating point number such as that which is returned by the python time module. Returns true if the object represents a date/time less than or equal to the specified DateTime or time module style time.""" try: return (self._... |
d=int(self._d+(self._tzinfo[self._tz].info(self._t)[0]/86400.0)) return int((d+jd1901)-self._julianday(self._year,1,0)) | d=int(self._d+(_tzoffset(self._tz, self._t)/86400.0)) return int((d+jd1901)-_julianday(self._year,1,0)) | def dayOfYear(self): """Return the day of the year, in context of the timezone representation of the object""" d=int(self._d+(self._tzinfo[self._tz].info(self._t)[0]/86400.0)) return int((d+jd1901)-self._julianday(self._year,1,0)) |
d,t,tz=(self._d+o),(self._t+(o*86400.0)),self._tz x=d+(self._tzinfo[tz].info(t)[0]/86400.0) yr,mo,dy=self._calendarday((x+jd1901)) s=(x-int(x))*86400.0 hr=int(s/3600) s=s-(hr*3600) mn=int(s/60) s=s-(mn*60) return self.__class__(yr,mo,dy,hr,mn,s,self._tz,t,d,(d-int(d))) | tz = self._tz t = (self._t + (o*86400.0)) d = (self._d + o) s = d - math.floor(d) ms = t - math.floor(t) x = _calcDependentSecond(tz, t) yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, ms) return self.__class__(yr,mo,dy,hr,mn,sc,self._tz,t,d,s) | def __add__(self,other): """A DateTime may be added to a number and a number may be added to a DateTime; two DateTimes cannot be added.""" if hasattr(other,'_t'): raise self.DateTimeError,'Cannot add two DateTimes' o=float(other) d,t,tz=(self._d+o),(self._t+(o*86400.0)),self._tz x=d+(self._tzinfo[tz].info(t)[0]/86400.... |
return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%g %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) | try: subsec = split('%g' % s, '.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: pass return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) | def __str__(self): """Convert a DateTime to a string.""" y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): if (s-int(s))> 0.0001: return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%g %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h... |
try: return cmp(self._d,obj._d) | try: return cmp(self.millis(), obj.millis()) | def __cmp__(self,obj): """Compare a DateTime with another DateTime object, or a float such as those returned by time.time(). |
return int(self._t) | return int(self.millis() / 1000) | def __int__(self): """Convert to an integer number of seconds since the epoch (gmt)""" return int(self._t) |
return long(self._t) | return long(self.millis() / 1000) | def __long__(self): """Convert to a long-int number of seconds since the epoch (gmt)""" return long(self._t) |
elif lower(strip(b))[:6]=='<html>': | elif lower(strip(b))[:6]=='<html>' or lower(strip(b))[:14]=='<!doctype html': | def exception(self, fatal=0, info=None, absuri_match=regex.compile( "^" "\(/\|\([a-zA-Z0-9+.-]+:\)\)" "[^\000- \"\\#<>]*" "\\(#[^\000- \"\\#<>]*\\)?" "$" ).match, tag_search=regex.compile('[a-zA-Z]>').search, ): if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info() |
Add an external method to an ObjectManager. | Add an external method to an 'ObjectManager'. | def manage_addExternalMethod(self, id, title, module, function): """ Add an external method to an ObjectManager. In addition to the standard object-creation arguments, 'id' and title, the following arguments are defined: function -- The name of the python function. This can be a an ordinary Python function, or a bou... |
Web-callable functions that encapsulate external python functions. | Web-callable functions that encapsulate external Python functions. | def manage_addExternalMethod(self, id, title, module, function): """ Add an external method to an ObjectManager. In addition to the standard object-creation arguments, 'id' and title, the following arguments are defined: function -- The name of the python function. This can be a an ordinary Python function, or a bou... |
Change the external method | Change the External Method. | def manage_edit(self, title, module, function, REQUEST=None): """ Change the external method |
Call an ExternalMethod | Call the External Method. | def __call__(self, *args, **kw): |
def testEmptyLists(self): self.assertEqual(len(mass_weightedIntersection([])), 0) self.assertEqual(len(mass_weightedUnion([])), 0) def testIdentity(self): t = IIBTree([(1, 2)]) b = IIBucket([(1, 2)]) for x in t, b: for func in mass_weightedUnion, mass_weightedIntersection: result = func([(x, 1)]) self.assertEqual(len(... | def mass_weightedUnion(L): "A list of (mapping, weight) pairs -> their weightedUnion IIBTree." if not L: return IIBTree() if len(L) == 1: x, weight = L[0] dummy, result = weightedUnion(IIBTree(), x, 1, weight) return result assert len(L) > 1 merge = NBest(len(L)) for x, weight in L: merge.add((x, weight), len(x)) wh... | def testEmptyLists(self): self.assertEqual(len(mass_weightedIntersection([])), 0) self.assertEqual(len(mass_weightedUnion([])), 0) |
class Navigation: | class Navigation(ExtensionClass.Base): | def tabs_path_info(self, script, path): url=script out=[] while path[:1]=='/': path=path[1:] while path[-1:]=='/': path=path[:-1] while script[:1]=='/': script=script[1:] while script[-1:]=='/': script=script[:-1] path=split(path,'/')[:-1] if script: path=[script]+path if not path: return '' script='' last=path[-1] del... |
pc.__propset_attrs__=tuple(map(lambda o: o[0], self._objects)) | pc.__propset_attrs__=tuple(map(lambda o: o['id'], self._objects)) | def _delOb(self, id): delattr(self, id) pc=self.aq_inner.aq_parent.aq_parent._zclass_propertysheets_class delattr(pc,id) pc.__propset_attrs__=tuple(map(lambda o: o[0], self._objects)) rclass(pc) |
""") | (%s)""" % repr(self)) | def __getstate__(self): raise SystemError, ( """This object was originally created by a product that is no longer installed. It cannot be updated. """) |
'manage_tabs','manage_propertiesForm','manage_UndoForm', 'objectIds', 'objectValues', 'objectItems','hasProperty',)), | 'manage_tabs','manage_propertiesForm','manage_UndoForm',)), | def manage_addFolder(self,id,title='',createPublic=0,createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ i=self.folderClass()() i.i... |
'multiple selection': field2lines, | def convert_unicode(self,v): return field2utext.convert_unicode(v).split('\n') | |
__import_error__=None | import_error_=None | def _canCopy(self, op=0): return 0 |
if hasattr(productp, '__import_error__'): ie=productp.__import_error__ | if hasattr(productp, 'import_error_'): ie=productp.import_error_ | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=get... |
hasattr(old, '__import_error__') and old.__import_error__==ie): | hasattr(old, 'import_error_') and old.import_error_==ie): | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=get... |
text="%s %s %s" % (text, api.SearchableText()) | text="%s %s" % (text, api.SearchableText()) | def SearchableText(self): "The full text of the Help Topic, for indexing purposes" text="%s %s" % (self.title, self.doc) for api in self.apis: text="%s %s %s" % (text, api.SearchableText()) return text |
!='text/html'): raise | !='text/html'): raise t, v, traceback | def zpublisher_exception_hook(published, REQUEST, t, v, traceback): try: if isinstance(t, StringType): if t.lower() in ('unauthorized', 'redirect'): raise else: if t is SystemExit: raise if issubclass(t, ConflictError): # First, we need to close the current connection. We'll # do this by releasing the hold on it. There... |
return self.manage_cacheParameters(self,REQUEST) | if REQUEST is not None: response=REQUEST['RESPONSE'] response.redirect(REQUEST['URL1']+'/manage_cacheParameters') | def manage_cache_age(self,value,REQUEST): "set cache age" try: v=self._p_jar.getVersion() except: # BoboPOS2: if self._p_jar.db is not Globals.Bobobase._jar.db: raise 'Version Error', ( '''You may not change the database cache age while working in a <em>version</em>''') self._cache_age=Globals.Bobobase._jar.cache.cache... |
return self.manage_cacheParameters(self,REQUEST) | if REQUEST is not None: response=REQUEST['RESPONSE'] response.redirect(REQUEST['URL1']+'/manage_cacheParameters') | def manage_cache_size(self,value,REQUEST): "set cache size" try: v=self._p_jar.getVersion() except: # BoboPOS2: if self._p_jar.db is not Globals.Bobobase._jar.db: raise 'Version Error', ( '''You may not change the database cache size while working in a <em>version</em>''') self._cache_size=Globals.Bobobase._jar.cache.c... |
return self.manage_cacheGC(self,REQUEST) | if REQUEST is not None: response=REQUEST['RESPONSE'] response.redirect(REQUEST['URL1']+'/manage_cacheGC') | def manage_full_sweep(self,value,REQUEST): "Perform a full sweep through the cache" try: db=self._p_jar.db() except: # BoboPOS2 Globals.Bobobase._jar.cache.full_sweep(value) else: db.cacheFullSweep(value) |
return self.manage_cacheGC(self,REQUEST) | if REQUEST is not None: response=REQUEST['RESPONSE'] response.redirect(REQUEST['URL1']+'/manage_cacheGC') | def manage_minimize(self,value,REQUEST): "Perform a full sweep through the cache" try: db=self._p_jar.db() except: # BoboPOS2 Globals.Bobobase._jar.cache.minimize(value) else: db.cacheMinimize(value) |
security.declareProtected('query', search_zcatalog) | security.declareProtected(search_zcatalog, 'query') | def getLexicon(self): """Get the lexicon for this index """ if hasattr(aq_base(self), 'lexicon'): # Fix up old ZCTextIndexes by removing direct lexicon ref # and changing it to an ID lexicon = getattr(aq_parent(aq_inner(self)), self.lexicon.getId()) self.lexicon_id = lexicon.getId() del self.lexicon |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.