rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
ws.factory("Minus[-1]"); ws.factory("$Alias(Addition_,sum_)") ;
ws.factory("Minus[-1]") ws.factory("$Alias(Addition_,sum_)")
def buildJpsiphi(ws, name) : buildAngularBasis(ws, abasis(ws,'trcospsi','trcostheta','trphi') ) # define the relevant combinations of strong amplitudes ws.factory("expr::NAzAz ('( @0 * @0 + @1 * @1 )',{ReAz,ImAz,ReAperp,ImAperp,ReApar,ImApar})") ws.factory("expr::NAparApar ('( @4 * @4 + @5 * @5 )',{ReAz,ImAz,ReA...
rc = 0 import re rexp = re.compile(pattern)
from ROOT import TRegexp, TString rc = int(0) rexp = TRegexp(pattern,True)
def setConstant(ws, pattern, constant = True, value = None): rc = 0 import re rexp = re.compile(pattern) for arg in ws.allVars() : if not rexp.match(arg.GetName()) : continue arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.s...
if not rexp.match(arg.GetName()) : continue arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.setVal(value) rc += 1
if TString(arg.GetName()).Index(rexp)>=0 : arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.setVal(value) rc += 1
def setConstant(ws, pattern, constant = True, value = None): rc = 0 import re rexp = re.compile(pattern) for arg in ws.allVars() : if not rexp.match(arg.GetName()) : continue arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.s...
if not rexp.match(arg) : continue
if not rexp.match(arg.GetName()) : continue
def setConstant(ws, pattern, constant = True, value = None): rc = 0 import re rexp = re.compile(pattern) for arg in ws.allVars() : if not rexp.match(arg) : continue arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.setVal(valu...
, _ba("AparAperp", [ ( 2,2,2,-1, sqrt( 9./15.)) ] ) , _ba("AzAperp", [ ( 2,1,2, 1,-sqrt(18./15.)) ] ) , _ba("AzApar", [ ( 2,1,2,-2, sqrt(18./15.)) ] )
, _ba("AparAperp", [ ( 2,2,2,-1, sqrt(3./5.)) ] ) , _ba("AzAperp", [ ( 2,1,2, 1, sqrt(6./5.)) ] ) , _ba("AzApar", [ ( 2,1,2,-2,-sqrt(6./5.)) ] )
def _ba(name,comp) : n = name + '_basis' s = RooArgSet() for c in comp : s.add( ab(name,c[0],c[1],c[2],c[3],c[4]) ) ws.put(RooAddition_( n, n, s ) ) return ws.function(n)
from ROOT import TRegexp, TString rc = int(0) rexp = TRegexp(pattern,True)
rc = 0 import re rexp = re.compile(pattern)
def setConstant(ws, pattern, constant = True, value = None): # TODO: replace TRegexp by native python re from ROOT import TRegexp, TString rc = int(0) rexp = TRegexp(pattern,True) for arg in ws.allVars() : if TString(arg.GetName()).Index(rexp)>=0 : arg.setConstant( constant ) if constant and value : if value < arg.getM...
if TString(arg.GetName()).Index(rexp)>=0 : arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.setVal(value) rc += 1
if not rexp.match(arg) : continue arg.setConstant( constant ) if constant and value : if value < arg.getMin() : arg.setMin(value) if value > arg.getMax() : arg.setMax(value) arg.setVal(value) rc += 1
def setConstant(ws, pattern, constant = True, value = None): # TODO: replace TRegexp by native python re from ROOT import TRegexp, TString rc = int(0) rexp = TRegexp(pattern,True) for arg in ws.allVars() : if TString(arg.GetName()).Index(rexp)>=0 : arg.setConstant( constant ) if constant and value : if value < arg.getM...
return ( _ba("AzAz", [ ( 0,0,0, 0, 2.), ( 0,0,2,0, sqrt(1./ 5.)), ( 0,0,2,2, -sqrt( 3./ 5.)) , ( 2,0,0, 0, 4.), ( 2,0,2,0, sqrt(4./ 5.)), ( 2,0,2,2, -sqrt(12./ 5.)) ] ) , _ba("AparApar", [ ( 2,2,0, 0, 1.), ( 2,2,2,0, sqrt(1./20.)), ( 2,2,2,2, sqrt( 3./20.)) ] ) , _ba("AperpAperp", [ ( 2,2,0, 0, 1.), ( 2,2,2,0,...
return ( _ba("AzAz", [ ( 0,0,0, 0, 2.), ( 0,0,2,0, sqrt(1./5.)), ( 0,0,2,2, -sqrt( 3./5.)) , ( 2,0,0, 0, 4.), ( 2,0,2,0, sqrt(4./5.)), ( 2,0,2,2, -sqrt(12./5.)) ] ) , _ba("AparApar", [ ( 2,2,0, 0, 2.), ( 2,2,2,0, sqrt(1./5.)), ( 2,2,2,2, sqrt( 3./5.)) ] ) , _ba("AperpAperp", [ ( 2,2,0, 0, 1.), ( 2,2,2,0,-sqrt(...
def _ba(name,comp) : n = name + '_basis' s = RooArgSet() for c in comp : s.add( ab(name,c[0],c[1],c[2],c[3],c[4]) ) ws.put(RooAddition_( n, n, s ) ) return ws.function(n)
, _ba("AzAperp", [ ( 2,1,2, 1,-sqrt(6./5.)) ] ) , _ba("AzApar", [ ( 2,1,2,-2,sqrt(6./5.)) ] )
, _ba("AzAperp", [ ( 2,1,2, 1, sqrt(6./5.)) ] ) , _ba("AzApar", [ ( 2,1,2,-2,-sqrt(6./5.)) ] )
def _ba(name,comp) : n = name + '_basis' s = RooArgSet() for c in comp : s.add( ab(name,c[0],c[1],c[2],c[3],c[4]) ) ws.put(RooAddition_( n, n, s ) ) return ws.function(n)
updateMainMenu(j)
def processFile(filename): """ Loads the given lang.XX.js file, processes it and saves it back to the file system """ in_file = open('./editor/locale/'+filename, 'r') in_string = in_file.read() in_file.close() try: j = json.loads(in_string) # process the JSON object here updateMainMenu(j) # now write it out back to ...
in_string = open('./editor/locale/'+filename).read()
in_file = open('./editor/locale/'+filename, 'r') in_string = in_file.read() in_file.close()
def processFile(filename): in_string = open('./editor/locale/'+filename).read() try: j = json.loads(in_string) pass except ValueError: print "ERROR! " + filename + " was not valid JSON, please fix it!"
pass
updateMainMenu(j) s = ourPrettyPrint(j).encode("UTF-8"); out_file = open('./editor/locale/'+filename, 'w') out_file.write( s ) out_file.close() print "Updated " + filename
def processFile(filename): in_string = open('./editor/locale/'+filename).read() try: j = json.loads(in_string) pass except ValueError: print "ERROR! " + filename + " was not valid JSON, please fix it!"
in_string = open('./editor/locale/' + filename, 'r').read()
in_string = open('../editor/locale/' + filename, 'r').read()
def processFile(filename): """ Loads the given lang.XX.js file, processes it and saves it back to the file system """ in_string = open('./editor/locale/' + filename, 'r').read() try: j = json.loads(in_string) # process the JSON object here changeTooltipTarget(j) # now write it out back to the file s = ourPrettyPrint...
open('./editor/locale/' + filename, 'w').write(s)
open('../editor/locale/' + filename, 'w').write(s)
def processFile(filename): """ Loads the given lang.XX.js file, processes it and saves it back to the file system """ in_string = open('./editor/locale/' + filename, 'r').read() try: j = json.loads(in_string) # process the JSON object here changeTooltipTarget(j) # now write it out back to the file s = ourPrettyPrint...
for file_name in os.listdir('./editor/locale/'):
for file_name in os.listdir('../editor/locale/'):
def processFile(filename): """ Loads the given lang.XX.js file, processes it and saves it back to the file system """ in_string = open('./editor/locale/' + filename, 'r').read() try: j = json.loads(in_string) # process the JSON object here changeTooltipTarget(j) # now write it out back to the file s = ourPrettyPrint...
resolution = eval(size)
resolution = eval(resolution)
def run(self): while True:
self._UpdatedDb = True
self._UpdatedDb = False
def clear (self) : self.Counter = 0 self.Jobs = {} self.Workers = {} self._ActiveJobs = set () self.addJob (0, Job ("Root", priority=1, retry=0)) self._UpdatedDb = True self._StAffinity = {} # static affinity self._DynAffinity = {} # dynamic affinity, job affinity concatened to the children jobs affinity
version = pickle.load(fo)
version = cPickle.load(fo)
def read (self, fo): version = pickle.load(fo) if version == DBVersion: self.Counter = pickle.load (fo) self.Jobs = pickle.load (fo) self.Workers = pickle.load (fo) self._refresh () #self.dump () else: raise Exception ("Database too old, erase the master_db file") self.clear ()
self.Counter = pickle.load (fo) self.Jobs = pickle.load (fo) self.Workers = pickle.load (fo)
self.Counter = cPickle.load (fo) self.Jobs = cPickle.load (fo) self.Workers = cPickle.load (fo)
def read (self, fo): version = pickle.load(fo) if version == DBVersion: self.Counter = pickle.load (fo) self.Jobs = pickle.load (fo) self.Workers = pickle.load (fo) self._refresh () #self.dump () else: raise Exception ("Database too old, erase the master_db file") self.clear ()
pickle.dump (version, fo) pickle.dump (self.Counter, fo) pickle.dump (self.Jobs, fo) pickle.dump (self.Workers, fo)
cPickle.dump (version, fo) cPickle.dump (self.Counter, fo) cPickle.dump (self.Jobs, fo) cPickle.dump (self.Workers, fo)
def write (self, fo): version = DBVersion pickle.dump (version, fo) pickle.dump (self.Counter, fo) pickle.dump (self.Jobs, fo) pickle.dump (self.Workers, fo) self._UpdatedDb = False #self.dump ()
if self._UpdatedDb or forceSaveDb:
if forceSaveDb:
def update (self, forceSaveDb = False) : global TimeOut _time = time.time () refreshActive = False for id in State._ActiveJobs.copy () : try: job = self.Jobs[id] if job.State == "WORKING": if _time - job.PingTime > TimeOut : # Job times out, no heartbeat received for too long output ("Job " + str(job.ID) + " is AWOL") ...
totalerror += 1
totalerrors += 1
def _upChildren (job) : total = 0 totalerrors = 0 totalfinished = 0 for cid in job.Children : child = self.Jobs[cid] _upChildren (child) total += child.Total totalerrors += child.TotalErrors totalfinished += child.TotalFinished if child.State == "ERROR": totalerror += 1 elif child.State == "FINISHED": totalfinished += ...
fo = open(dataDir + "/master_db.part", "wb") try: State.write (fo) fo.close() try: os.remove (dataDir + '/master_db') except OSError: pass os.rename (dataDir + '/master_db.part', dataDir + '/master_db') except IOError: fo.close() output ("DB saved")
global GErr, GOk if State._UpdatedDb: fo = open(dataDir + "/master_db.part", "wb") try: State.write (fo) fo.close() try: os.remove (dataDir + '/master_db') except OSError: pass os.rename (dataDir + '/master_db.part', dataDir + '/master_db') except IOError: fo.close() output ("DB saved") reactor.callLater(5, saveDb)
def saveDb (): global State, dataDir fo = open(dataDir + "/master_db.part", "wb") try: State.write (fo) fo.close() try: os.remove (dataDir + '/master_db') except OSError: pass os.rename (dataDir + '/master_db.part', dataDir + '/master_db') except IOError: fo.close() output ("DB saved")
except:
except Exception as inst: print inst.args
def readDb (): global State, dataDir output ("Read DB") try: fo = open(dataDir + "/master_db", "rb") try: State.read (fo) except: fo.close() print ("Error reading master_db, create a new one") State = CState() except: output ("No db found, create a new one") State = CState() return output ("DB is OK") # Touch every wor...
date = lang_obj.strftime(datas['form']['date'].timetuple(), lang.code, lang.date)
date = lang_obj.strftime(datas['form']['date'], lang.code, lang.date)
def _action_open(self, cursor, user, datas, context=None): if context is None: context = {} model_data_obj = self.pool.get('ir.model.data') act_window_obj = self.pool.get('ir.action.act_window') company_obj = self.pool.get('company.company') lang_obj = self.pool.get('ir.lang')
if not line.tax_lines and line.account.taxes: if line.account.id in no_code_taxes: taxes[(line.account.id, False, False)] = True else: no_code_taxes.append(line.account.id) elif not line.tax_lines: taxes[(line.account.id, False, False)] = True
if not line.tax_lines: no_code_taxes.append(line.account.id) for no_code_account_id in no_code_taxes: for (account_id, code_id, tax_id), test in \ taxes.iteritems(): if (not test and not code_id and no_code_account_id == account_id): taxes[(account_id, code_id, tax_id)] = True
def default_get(self, fields, with_rec_name=True): move_obj = self.pool.get('account.move') tax_obj = self.pool.get('account.tax') account_obj = self.pool.get('account.account') tax_code_obj = self.pool.get('account.tax.code') currency_obj = self.pool.get('currency.currency') values = super(Line, self).default_get(fiel...
self.assertRaises(Exception, test_view('account'))
test_view('account')
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('account'))
'required': Or(Bool(Eval('centralised')), And(Equal(Eval('type'), 'cash'), Bool(Get(Eval('context', {}), 'company', 0)))),
'required': And(Or(Bool(Eval('centralised')), Equal(Eval('type'), 'cash')), Bool(Get(Eval('context', {}), 'company', 0))),
def default_readonly(self): return False
res2 = self.get_balance(cursor, user, ids, name, arg, context=ctx)
res2 = self.get_balance(cursor, user, ids, name, context=ctx)
def get_balance(self, cursor, user, ids, name, context=None): res = {} company_obj = self.pool.get('company.company') currency_obj = self.pool.get('currency.currency') move_line_obj = self.pool.get('account.move.line') fiscalyear_obj = self.pool.get('account.fiscalyear') deferral_obj = self.pool.get('account.account.de...
:param arg: optional argument
def get_credit_debit(self, cursor, user, ids, names, context=None): ''' Function to compute debit, credit for account ids.
res2 = self.get_credit_debit(cursor, user, ids, names, arg,
res2 = self.get_credit_debit(cursor, user, ids, names,
def get_credit_debit(self, cursor, user, ids, names, context=None): ''' Function to compute debit, credit for account ids.
if not fiscalyear_ids: fiscalyear_ids = [0]
fiscalyear_id = fiscalyear_ids and fiscalyear_ids[0] or 0
def query_get(self, cursor, user, obj='l', context=None): ''' Return SQL clause and fiscal years for account move line depending of the context.
str(fiscalyear_ids[0]) + ' ' \
str(fiscalyear_id) + ' ' \
def query_get(self, cursor, user, obj='l', context=None): ''' Return SQL clause and fiscal years for account move line depending of the context.
('create_uid', '=', user),
('create_uid', '=', Transaction().user),
def default_get(self, fields, with_rec_name=True): move_obj = self.pool.get('account.move') tax_obj = self.pool.get('account.tax') account_obj = self.pool.get('account.account') tax_code_obj = self.pool.get('account.tax.code') currency_obj = self.pool.get('currency.currency') values = super(Line, self).default_get(fiel...
res = act_window_obj.read(cursor, user, model_data.db_id, context=context)
res = act_window_obj.read(cursor, user, act_window_id, context=context)
def _action_open(self, cursor, user, datas, context=None): if context is None: context = {} model_data_obj = self.pool.get('ir.model.data') act_window_obj = self.pool.get('ir.action.act_window') period_obj = self.pool.get('account.period')
if not line.tax_lines and line.account.taxes: if line.account.id in no_code_taxes: taxes[(line.account.id, False, False)] = True else: no_code_taxes.append(line.account.id) elif not line.tax_lines: taxes[(line.account.id, False, False)] = True
if not line.tax_lines: no_code_taxes.append(line.account.id) for no_code_account_id in no_code_taxes: for (account_id, code_id, tax_id), test in \ taxes.iteritems(): if (not test and not code_id and no_code_account_id == account_id): taxes[(account_id, code_id, tax_id)] = True
def default_get(self, cursor, user, fields, context=None, with_rec_name=True): if context is None: context = {} move_obj = self.pool.get('account.move') tax_obj = self.pool.get('account.tax') account_obj = self.pool.get('account.account') tax_code_obj = self.pool.get('account.tax.code') currency_obj = self.pool.get('cu...
partial_paths.add(p)
partial_paths.append(p)
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
for i in reversed(range(indent+1, old_indent+1)): index += TAB*i + "</ul>\n"
for i in reversed(range(indent, old_indent)): index += TAB*(i+1) + "</ul>\n"
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
partial_paths = set()
partial_paths = []
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
parset.add_option("-t","--tmax", type="int", dest="tmax", default=300000, help="Maximum time interval [s] [default: %default]")
parser.add_option("-t","--tmax", type="int", dest="tmax", default=30000, help="Maximum time interval [s] [default: %default]")
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
x = xfactorSmall * tau
x = xfactorSmall * tauSmall
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
outfile=open(outputfile,'w')
outfile=open(options.outputfile,'w')
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
logflux = line[options.fluxLoc]
logflux = float(line[options.fluxLoc])
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
fy=array()
fy=array([])
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
fysize=nstepSmall
size=nstepSmall
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
newy[0:size+1] = abs_fy[0:size+1] * cphases newy[size+1:] = abs_fy[size+1:]*cphases.conjugate()[:0:-1]
newy[0:size+1] = fy[0:size+1] * cphases newy[size+1:] = fy[size+1:]*cphases.conjugate()[:0:-1]
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
newflux = pow(10,f)*(1 + delta)
newflux = pow(10,logflux)*(1 + delta)
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
elapsedTime=array()
elapsedTime=array([])
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
elapsedTime = double(range(tauSmall.size))*step
elapsedTime = double(range(tauSmall.size))*options.step
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
elapsedTime = double(range(tau.size))*step
elapsedTime = double(range(tau.size))*options.step
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
outfile.write(component+" ")
outfile.write("%s %7.4f "%(component,logflux))
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
outfile.write("%12.8f "%f)
outfile.write("%12.8e "%max(f,0.))
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
index += TAB*old_indent + "</ul>\n"
for i in reversed(range(indent+1, old_indent+1)): index += TAB*i + "</ul>\n"
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
cmd = 'find %s -name %s | sed "s if DEBUG: print ' ', cmd PKGS = os.popen(cmd)
for subdir in ['Base', 'Interfaces', 'Components', 'Systems']: cmd = 'find %s/%s -name %s | sed "s if DEBUG: print ' ', cmd PKGS += os.popen(cmd).readlines()
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
if old_indent > indent: index += TAB*old_indent + "</ul>\n"
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
f = open('/tmp/index.html', 'w') f.write(index) f.close()
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
if abs(stats['peak']-1.)>0.02:
if abs(stats['peak']-1.)>0.1:
def analyseResult(spr): ''' spr - synthesis program runner (to run imageStats) throws exceptions if something is wrong, otherwise just returns ''' src_offset = 0.006/math.pi*180. psf_peak=[-172.5,-45] true_peak=sinProjection(psf_peak,src_offset,src_offset) stats = spr.imageStats('image.field1.restored') print "Statist...
print "DEBUG...."
def run(self): for cmd_name in self.get_sub_commands(): print "DEBUG...." self.run_command(cmd_name)
def BuildTree(path, partial_paths, old_indent):
def BuildTree(path, partial_paths):
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
Given a package directory path, return indented HTML list items of the path.
Given a package directory path, return list of tuples containing indent level and directory name of partial paths.
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
index = ''
items = []
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
indent = len(p.split('/')) if indent < old_indent: for i in reversed(range(indent, old_indent)): index += TAB*(i+1) + "</ul>\n" index += TAB*indent + "<li> %s </li>\n" % comp index += TAB*(indent+1) + "<ul>\n" if len(partial_paths) > 1 and p == partial_paths[-2]: index += TAB*old_indent + "</ul\n>" return index
items.append((len(p.split('/')), "<li> %s </li>" % comp)) return items
def BuildTree(path, partial_paths, old_indent): ''' Given a package directory path, return indented HTML list items of the path. Need to keep track of partial paths already seen. ''' path_components = path.split('/') p = '' index = '' for comp in path_components[0:-1]: p += comp + '/' if not p in partial_paths: parti...
indent = 0
orig_indent = 2 old_indent = orig_indent
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
index += TAB*2 + "<ul>\n"
index += TAB*orig_indent + "<ul>\n"
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
old_indent = indent index += BuildTree(subtree, partial_paths, old_indent)
items += BuildTree(subtree, partial_paths)
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
index += TAB*indent + \ '<li><a href="%s"> %s </a></li>\n' % (subtree, pkg)
items += [(indent, '<li><a href="%s">%s</a></li>' % (subtree, pkg))]
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
for i in reversed(range(2, indent+1)):
for i in reversed(range(orig_indent, indent+1)):
def CopyDocs(doc_type, doc_loc, find_term): ''' The ASKAPsoft system uses different type of documentation depending on the language used. e.g. java -> javadocs, python -> sphinx, C++ -> doxygen This is the "doc_type" parameter. The documentation is produced in different locations depending on the type. This is the "do...
alpha = log10(s1400/s0610)/log10(1400./610.)
alpha = (s1400-s0610)/log10(1400./610.)
def getTabName(x,y,type): ''' Return a SKADS S3SEX components table name based on the position offset and the source type ''' xsign='' if(x<0): xsign='m' elif(x>0): xsign='p' ysign='' if(y<0): ysign='m' elif(y>0): ysign='p' name="Components_%s_%s%d_%s%d"%(type,xsign,abs(x),ysign,abs(y)) return name
catfile.write("%10.6f %10.6f %20.16f %10.6f %10.6f %10.6f %10.6f %10.6f\n"%(ra,dec,s1400,alpha,beta,maj,min,pa))
catfile.write("%10.6f %10.6f %20.16f %20.16f %10.6f %10.6f %10.6f %10.6f %10.6f\n"%(ra,dec,s1400,flux0,alpha,beta,maj,min,pa))
def getTabName(x,y,type): ''' Return a SKADS S3SEX components table name based on the position offset and the source type ''' xsign='' if(x<0): xsign='m' elif(x>0): xsign='p' ysign='' if(y<0): ysign='m' elif(y>0): ysign='p' name="Components_%s_%s%d_%s%d"%(type,xsign,abs(x),ysign,abs(y)) return name
parser.add_option("-f","--fluxCol", type="int", dest="fluxLoc", default=11, help="Column in input file with flux [default: %default]")
parser.add_option("-f","--fluxCol", type="int", dest="fluxLoc", default=10, help="Column in input file with flux [default: %default]")
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
s0=6.4e7
s0=3.164e7
def flux2size(flux,lam=0.21): k=1.3807e-23 T=1.e12 return sqrt(lam**2 * flux * 1.e-26 / (2.*pi*k*T))
exec expr in self.doc.datamodel
try: exec expr in self.doc.datamodel except: sys.stderr.write("Error occurred while executing expression: '%s'\n" % expr) raise
def f(): exec expr in self.doc.datamodel
return eval(expr, self.doc.datamodel)
try: return eval(expr, self.doc.datamodel) except: sys.stderr.write("Error occurred while executing expression: '%s'\n" % expr) raise
def getExprValue(self, expr): """These expression are always one-line, so their value is evaluated and returned.""" if not expr: return None expr = unescape(expr) return eval(expr, self.doc.datamodel)
if not conf.MYSQL_HOST is None:
if not conf.POSTGRESQL_HOST is None:
def __init__(self): """ Constructs the broker. """ self._connection_details = { 'database': conf.POSTGRESQL_DATABASE, 'user': conf.POSTGRESQL_USERNAME, 'password': conf.POSTGRESQL_PASSWORD, } if not conf.MYSQL_HOST is None: self._connection_details['host'] = conf.POSTGRESQL_HOST self._connection_details['port'] = conf....
__getstate__ = freeze
def freeze(self, skipSet = None): if type(self._members) == str: return self._members else: return misc.depSetFreeze(self.members);
__setstate__ = __init__
def __init__(self, frz = None): if frz is not None: frz = intern(frz) self._members = frz else: self._members = ''
def proxyBypass(self, proxy, host):
def proxyBypass(self, proxy, host, useConaryProxy):
def proxyBypass(self, proxy, host): if self.forceProxy: return False # Split the port and username/pass from proxy proxyHost = urllib.splituser(urllib.splitport(proxy)[0])[1]
if not useConaryProxy and self.proxyBypass(host, realhost):
if self.proxyBypass(host, realhost, useConaryProxy):
def createConnection(self, url, ssl=False, withProxy=False): # Return an HTTP or HTTPS class suitable for use by open_http self.usedProxy = False if ssl: protocol='https' else: protocol='http'
repo.remove(files, unlink=True)
wlock = repo.wlock() try: for name in files: os.unlink(name) repo.dirstate.remove(name) finally: wlock.release()
def generate(repo): version = _getVersion() old = open('NEWS').read() if '@NEW@' in old: sys.exit("error: NEWS contains a @NEW@ section") elif ('Changes in %s:' % version) in old: sys.exit("error: NEWS already contains a %s section" % version) lines, htmlLines, files = preview(repo, modifiedOK=False) new = '\n'.join(l...
url, sizes = self._saveFileContentsChangeset(fileList)
url, sizes = self._saveFileContentsChangeset(clientVersion, fileList)
def getFileContents(self, caller, authToken, clientVersion, fileList, authCheckOnly = False): if clientVersion < 42: # server doesn't support auth checks through getFileContents return caller.getFileContents(clientVersion, fileList, authCheckOnly)
for x in flags if x ]
for x in rpmflags if x ]
def _getDepsetFromHeader(self, tag): depset = deps.DependencySet() flagre = re.compile('\((.*?)\)') depnamere = re.compile('(.*?)\(.*') localere = re.compile('locale\((.*):(.*)\)') packageName = self.get(NAME, '')
trv = self.cache.getTrove(*troveTup, withFiles = False) provTrv = self.cache.getTrove(*provTroveTup, withFiles = False)
trv = self.cache.getTrove(withFiles = False, *troveTup) provTrv = self.cache.getTrove(withFiles = False, *provTroveTup)
def getReasonString(self, name, version, flavor): reason = self.reasons[name, version, flavor] if reason is None: return "Added for an unknown reason"
if written != sizeLimit:
if sizeLimit is not None and written != sizeLimit:
def set(self, key, value): (csInfo, inF, sizeLimit) = value
CpioHeader.HeaderLength, len(buf)))
amt, len(buf)))
def _readExact(self, amt, eofOK = False): buf = self.stream.read(amt) if not buf and eofOK: return None if len(buf) != amt: raise ShortReadError("Expected %d bytes, got %d" % ( CpioHeader.HeaderLength, len(buf))) self._currentPosition += amt return buf
stream = self.environ['wsgi.input']
try: stream = self._getStream() except WrappedResponse, wrapper: yield wrapper.response
def _iter_post(self): """POST method -- handle XMLRPC requests"""
def derive(repos, cfg, targetLabel, troveSpec, checkoutDir = None,
def derive(repos, cfg, targetLabel, troveToDerive, checkoutDir = None,
def derive(repos, cfg, targetLabel, troveSpec, checkoutDir = None, extract = False, info = False, callback = None): """ Creates a derived recipe. Note that is does not actually commit anything to the repository. Finally if extract = True, it installs an version of the binary package into a root. @param repos: troveso...
troveName, versionSpec, flavor = conaryclient.cmdline.parseTroveSpec( troveSpec)
if isinstance(troveToDerive,tuple): troveName, versionSpec, flavor = troveToDerive versionSpec = str(versionSpec) troveSpec = conaryclient.cmdline.toTroveSpec(troveName, versionSpec, flavor) else: troveSpec = troveToDerive troveName, versionSpec, flavor = conaryclient.cmdline.parseTroveSpec( troveSpec) if isinstance(...
def derive(repos, cfg, targetLabel, troveSpec, checkoutDir = None, extract = False, info = False, callback = None): """ Creates a derived recipe. Note that is does not actually commit anything to the repository. Finally if extract = True, it installs an version of the binary package into a root. @param repos: troveso...
nvfToDerive, = repos.findTrove(cfg.buildLabel, (troveName, versionSpec, flavor), cfg.flavor) troveToDerive = repos.getTrove(*nvfToDerive)
def derive(repos, cfg, targetLabel, troveSpec, checkoutDir = None, extract = False, info = False, callback = None): """ Creates a derived recipe. Note that is does not actually commit anything to the repository. Finally if extract = True, it installs an version of the binary package into a root. @param repos: troveso...
raise BranchError('\n\n'.join(msg))
raise errors.BranchError('\n\n'.join(msg))
def derive(repos, cfg, targetLabel, troveSpec, checkoutDir = None, extract = False, info = False, callback = None): """ Creates a derived recipe. Note that is does not actually commit anything to the repository. Finally if extract = True, it installs an version of the binary package into a root. @param repos: troveso...
pass
''' In this recipe, you can make modifications to the package.
def setup(r): pass
recipeBaseClass=derivedRecipeType)
recipeBaseClass=derivedRecipeType, removeText=removeText)
def setup(r): pass
cwd = os.getcwd()
cwd = ''
def _freezeFromChangesets(self): ret = [] cwd = os.getcwd() for f in self._fromChangesets: if not f.fileName: continue fn = f.fileName if not fn.startswith('/'): fn = util.joinPaths(cwd, fn) ret.append(fn) return ret
passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
passwdMgr = self.BasicPasswordManager()
def _fetchUrl(self, url, headers): retries = 0 inFile = None while retries < 5: try: # set up a handler that tracks cookies to handle # sites like Colabnet that want to set a session cookie cj = cookielib.LWPCookieJar() passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm() if self.cfg.proxy and \ not self.noproxyFilter...
proxyPasswdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
proxyPasswdMgr = urllib2.HTTPPasswordMgr()
def _fetchUrl(self, url, headers): retries = 0 inFile = None while retries < 5: try: # set up a handler that tracks cookies to handle # sites like Colabnet that want to set a session cookie cj = cookielib.LWPCookieJar() passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm() if self.cfg.proxy and \ not self.noproxyFilter...
passwdMgr.add_password(None, urlStr, url.user, url.passwd)
passwdMgr.add_password(url.user, url.passwd)
def _fetchUrl(self, url, headers): retries = 0 inFile = None while retries < 5: try: # set up a handler that tracks cookies to handle # sites like Colabnet that want to set a session cookie cj = cookielib.LWPCookieJar() passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm() if self.cfg.proxy and \ not self.noproxyFilter...
origTrv = self.db.getTrove(*thisTrv.getNameVersionFlavor(), **{pristine: True})
origTrv = self.db.getTrove(pristine = True, *thisTrv.getNameVersionFlavor())
def _recurseTrove(self, trv, duplicateFilterSet = None): verifyList = []
path = self.parent.path + (self.parent.params or '')
path = self.parent.path + (self.parent.params and '?%s' % self.parent.params or '')
def filePath(self, useParentPath=True): if self.parent and useParentPath: fragment = self.parent.fragment or '' port = self.parent.port or '' path = self.parent.path + (self.parent.params or '') host = self.parent.host else: fragment = self.fragment or '' port = self.port or '' path = self.path + (self.params and '?%s'...
fileName, lineNo, funcName, text, idx = inspect.getframeinfo(frame)
try: frameInfo = inspect.getframeinfo(frame, context=1) except: frameInfo = inspect.getframeinfo(frame, context=0) fileName, lineNo, funcName, text, idx = frameInfo
def updatecache(*args): # linecache.updatecache looks in the module search path for # files that match the module name. This is a problem if you # have a file without source with the same name as a python # standard library module. We'll just check to see if the file # exists first and require exact path matches. if no...
if not modelFile.exists():
if not modelFile.exists() and not kwargs.get('ignore-model'):
def runCommand(self, cfg, argSet, otherArgs): kwargs = { 'systemModel': False } model = cml.CML(cfg) modelFile = systemmodel.SystemModelFile(model)
if modelFile.exists():
if modelFile.exists() and not kwargs.pop('ignoreModel'):
def runCommand(self, cfg, argSet, otherArgs): kwargs = { 'systemModel': False } model = cml.CML(cfg) modelFile = systemmodel.SystemModelFile(model)