rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return self.bugs_closed.split(',')
bugs = self.bugs_closed.split(',') bugs.sort(cmp=lambda x,y: int(x) - int(y)) return bugs
def get_bug_list(self): return self.bugs_closed.split(',')
3a22e515c9eaba49586a9446d3d06a202fb9e702 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/3a22e515c9eaba49586a9446d3d06a202fb9e702/models.py
", ".join(re.split(r"[, ]+", changedesc_keys['Bug Number']))
", ".join(re.split(r"[, ]+", changedesc_keys['Bug Number'])).strip()
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None for line in changedesc.split("\n"): if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] result_dict['bugs_closed'] = \ ", ".join(re.split(r"[, ]+", changedesc_keys['Bug Number'])) # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
2b1e78d93b460392f1c45a43c8787c7e47800ff0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/2b1e78d93b460392f1c45a43c8787c7e47800ff0/views.py
def new_review_request(request, template_name='reviews/new.html', changenum_path='changenum'): changedesc = "\
2b1e78d93b460392f1c45a43c8787c7e47800ff0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/2b1e78d93b460392f1c45a43c8787c7e47800ff0/views.py
changenum = request.POST['changenum'] if changenum:
if request.POST.has_key('changenum'): changenum = request.POST['changenum']
def new_review_request(request, template_name='reviews/new.html', changenum_path='changenum'): changedesc = "\
2b1e78d93b460392f1c45a43c8787c7e47800ff0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/2b1e78d93b460392f1c45a43c8787c7e47800ff0/views.py
self.assertEquals(r.toString(), "SIP/2.0 200 OK\r\nFoo: bar\r\nContent-length: 4\r\n\r\n1234")
self.assertEquals(r.toString(), "SIP/2.0 200 OK\r\nFoo: bar\r\nContent-Length: 4\r\n\r\n1234")
def testResponse(self): r = sip.Response(200, "OK") r.addHeader("foo", "bar") r.addHeader("Content-Length", "4") r.bodyDataReceived("1234") self.assertEquals(r.toString(), "SIP/2.0 200 OK\r\nFoo: bar\r\nContent-length: 4\r\n\r\n1234")
b1ee060a816f8fbd1f7232060199441e1c2161d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6979/b1ee060a816f8fbd1f7232060199441e1c2161d7/test_sip.py
Content-length: 0\r
Content-Length: 0\r
def testRegister(self): p = self.clientPort.getHost().port r = sip.Request("REGISTER", "sip:proxy.com") r.addHeader("to", "sip:[email protected]") r.addHeader("from", "sip:[email protected]") r.addHeader("contact", "sip:[email protected]:%d" % p) r.addHeader("call-id", "[email protected]") r.addHeader("CSeq", "25317 REGISTER") r.addHeader("via", sip.Via("127.0.0.1", port=p).toString()) self.clientTransport.sendRequest(r, ("127.0.0.1", self.serverPortNo)) while not len(self.client.received): reactor.iterate() self.assertEquals(len(self.client.received), 1) r = self.client.received[0] self.assertEquals(r.code, 200)
b1ee060a816f8fbd1f7232060199441e1c2161d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6979/b1ee060a816f8fbd1f7232060199441e1c2161d7/test_sip.py
la = avatar.parent.findFirst(userbase.LoginAccount, avatars=avatar.parent.getItemByID(avatar.idInParent))
la = avatar.parent.findFirst( userbase.LoginAccount, userbase.LoginAccount.avatars == avatar.parent.getItemByID(avatar.idInParent))
def endow(self, ticket, avatar): self.endowed += 1 la = avatar.parent.findFirst(userbase.LoginAccount, avatars=avatar.parent.getItemByID(avatar.idInParent))
0de92762adf2f380e4922f6ea0c5fa9e0c203b62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6979/0de92762adf2f380e4922f6ea0c5fa9e0c203b62/sipserver.py
return [webnav.Tab('Voice', self.storeID, 0.0)]
return [webnav.Tab('Voice', self.storeID, 0.75)]
def getTabs(self): return [webnav.Tab('Voice', self.storeID, 0.0)]
12cdf3749078c08d579123d4f908692ec3cd1c8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6979/12cdf3749078c08d579123d4f908692ec3cd1c8f/sipserver.py
def readRecord(self): #FIXME this is not optimal since we need wo walk at least through 256*256 cells. It #would be better, if we reuse KSpread::Cell::firstCell()-iterator here. if self.rowidx <= self.sheet.lastRow(): record = [] for i in range(self.sheet.lastColumn() + 1, 1, -1): value = self.sheet.text(i, self.rowidx) #print "col=%i row=%i value=%s" % (i, self.rowidx, value) if value or len(record) > 0: record.insert(0,value) self.rowidx += 1 if self.progress: self.progress.value = self.rowidx return record print "EXPORT DONE rowidx=%i lastRow=%i lastColumn=%i" % (self.rowidx, self.sheet.lastRow(), self.sheet.lastColumn()) return None
064a3b928f06883577daf0a3540569d8598a014e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/064a3b928f06883577daf0a3540569d8598a014e/htmlexport.py
self.bctype="0"
self.bctype="0"
def __reset(self): self.alignment="1" #text alignment, left self.vgap=1 #line spacing
ae3ba91c5fa7f5d0cde0814f996bd990021eff11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/ae3ba91c5fa7f5d0cde0814f996bd990021eff11/mgp2kpr.py
self.__setBackground(bgParent)
if (self.pageCount!=-1): self.__setBackground(bgParent)
def __handlePage(self,parent,bgParent): self.__setBackground(bgParent) #set the background for this page self.pageCount=self.pageCount+1 objElem=self.document.createElement("OBJECT") #KPresenter text object objElem.setAttribute("type", "4")
ae3ba91c5fa7f5d0cde0814f996bd990021eff11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/ae3ba91c5fa7f5d0cde0814f996bd990021eff11/mgp2kpr.py
paperElem.setAttribute("ptWidth", "680")
paperElem.setAttribute("ptWidth", str(PAGE_WIDTH))
def __setPaper(self,parent): paperElem=self.document.createElement("PAPER") paperElem.setAttribute("ptWidth", "680") paperElem.setAttribute("ptHeight", str(Y_OFFSET)) paperElem.setAttribute("orientation", "0") #landscape paperElem.setAttribute("format", "5") #screen paperElem.setAttribute("unit", "0") #mm
ae3ba91c5fa7f5d0cde0814f996bd990021eff11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/ae3ba91c5fa7f5d0cde0814f996bd990021eff11/mgp2kpr.py
self.assert_( self.pluginobject1 )
def setUp(self): import krosstestpluginmodule self.pluginobject1 = krosstestpluginmodule.testpluginobject1() self.pluginobject2 = krosstestpluginmodule.testpluginobject2() self.assert_( self.pluginobject1 ) self.assert_( self.pluginobject2 )
709dcf73a39047e96138474ab2dc4ae54a206438 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/709dcf73a39047e96138474ab2dc4ae54a206438/testcase.py
print "__name = %s" % __name__
print "__name__ = %s" % __name__
#def testExpectedFailures(self): # to less arguments #self.assertRaises(ValueError, self.pluginobject1.uintfunc) #self.assert_( self.pluginobject1.uintfunc() != 8465 )
709dcf73a39047e96138474ab2dc4ae54a206438 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/709dcf73a39047e96138474ab2dc4ae54a206438/testcase.py
self.setCaption("Actions")
self.setCaption("Script Editor")
def __init__(self, scriptpath, parent): self.scriptpath = scriptpath self.filename = self.getFileName("myscript.py")
fe9fe58d375f2cd71b421c1948345f0991620829 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1674/fe9fe58d375f2cd71b421c1948345f0991620829/ScriptEditor.py
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount):
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount, round=True):
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount): if to_currency_id==from_currency_id: return from_amount [from_currency]=self.read(cr, uid, [from_currency_id]) [to_currency] = self.read(cr, uid, [to_currency_id]) if from_currency['rate'] == 0 or to_currency['rate'] == 0: raise osv.except_osv('Error', 'No rate found for the currency') return self.round(cr, uid, to_currency, from_amount * from_currency['rate']/to_currency['rate'])
4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9/res_currency.py
[from_currency]=self.read(cr, uid, [from_currency_id]) [to_currency] = self.read(cr, uid, [to_currency_id])
from_currency=self.browse(cr, uid, [from_currency_id])[0] to_currency = self.browse(cr, uid, [to_currency_id])[0]
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount): if to_currency_id==from_currency_id: return from_amount [from_currency]=self.read(cr, uid, [from_currency_id]) [to_currency] = self.read(cr, uid, [to_currency_id]) if from_currency['rate'] == 0 or to_currency['rate'] == 0: raise osv.except_osv('Error', 'No rate found for the currency') return self.round(cr, uid, to_currency, from_amount * from_currency['rate']/to_currency['rate'])
4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9/res_currency.py
return self.round(cr, uid, to_currency, from_amount * from_currency['rate']/to_currency['rate'])
if round: return self.round(cr, uid, to_currency, from_amount * from_currency.rate/to_currency.rate) else: return (from_amount * from_currency.rate/to_currency.rate)
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount): if to_currency_id==from_currency_id: return from_amount [from_currency]=self.read(cr, uid, [from_currency_id]) [to_currency] = self.read(cr, uid, [to_currency_id]) if from_currency['rate'] == 0 or to_currency['rate'] == 0: raise osv.except_osv('Error', 'No rate found for the currency') return self.round(cr, uid, to_currency, from_amount * from_currency['rate']/to_currency['rate'])
4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/4cbcb3ede718249b78b46ac0572d0e6c6c8c88b9/res_currency.py
obj_pool = {} module_object_list = {}
def __init__(self, name, value, exc_type='warning'): self.name = name self.exc_type = exc_type self.value = value self.args = (exc_type,name)
e7d25212a04af55cd41efe807e4b0e5a2c591d07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/e7d25212a04af55cd41efe807e4b0e5a2c591d07/osv.py
print 'INDENT'
def _tag_menuitem(self, cr, rec, data_node=None): rec_id = rec.getAttribute("id").encode('ascii') m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8'))) pid = False for idx, menu_elem in enumerate(m_l): if pid: cr.execute('select id from ir_ui_menu where parent_id=%d and name=%s', (pid, menu_elem)) else: cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,)) res = cr.fetchone() if idx==len(m_l)-1: # we are at the last menu element/level (it's a leaf) values = {'parent_id': pid,'name':menu_elem}
29a1e47fb1295ff56a6f74368f7337fbbb92177b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/29a1e47fb1295ff56a6f74368f7337fbbb92177b/convert.py
print 'FILL'
def _tag_menuitem(self, cr, rec, data_node=None): rec_id = rec.getAttribute("id").encode('ascii') m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8'))) pid = False for idx, menu_elem in enumerate(m_l): if pid: cr.execute('select id from ir_ui_menu where parent_id=%d and name=%s', (pid, menu_elem)) else: cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,)) res = cr.fetchone() if idx==len(m_l)-1: # we are at the last menu element/level (it's a leaf) values = {'parent_id': pid,'name':menu_elem}
29a1e47fb1295ff56a6f74368f7337fbbb92177b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/29a1e47fb1295ff56a6f74368f7337fbbb92177b/convert.py
print 'COLOR'
def _tag_menuitem(self, cr, rec, data_node=None): rec_id = rec.getAttribute("id").encode('ascii') m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8'))) pid = False for idx, menu_elem in enumerate(m_l): if pid: cr.execute('select id from ir_ui_menu where parent_id=%d and name=%s', (pid, menu_elem)) else: cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,)) res = cr.fetchone() if idx==len(m_l)-1: # we are at the last menu element/level (it's a leaf) values = {'parent_id': pid,'name':menu_elem}
29a1e47fb1295ff56a6f74368f7337fbbb92177b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/29a1e47fb1295ff56a6f74368f7337fbbb92177b/convert.py
print values
def _tag_menuitem(self, cr, rec, data_node=None): rec_id = rec.getAttribute("id").encode('ascii') m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8'))) pid = False for idx, menu_elem in enumerate(m_l): if pid: cr.execute('select id from ir_ui_menu where parent_id=%d and name=%s', (pid, menu_elem)) else: cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,)) res = cr.fetchone() if idx==len(m_l)-1: # we are at the last menu element/level (it's a leaf) values = {'parent_id': pid,'name':menu_elem}
29a1e47fb1295ff56a6f74368f7337fbbb92177b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/29a1e47fb1295ff56a6f74368f7337fbbb92177b/convert.py
if not self.field_id:
if not self.field_id.get(cr.dbname):
def _field_get(self, self2, cr, uid, prop): if not self.field_id: cr.execute('select id from ir_model_fields where name=%s and model=%s', (prop, self2._name)) res = cr.fetchone() self.field_id = res and res[0] return self.field_id
7361d410cefc08e39f421aa1e054c2ad659dca1e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/7361d410cefc08e39f421aa1e054c2ad659dca1e/fields.py
self.field_id = res and res[0] return self.field_id
self.field_id[cr.dbname] = res and res[0] return self.field_id[cr.dbname]
def _field_get(self, self2, cr, uid, prop): if not self.field_id: cr.execute('select id from ir_model_fields where name=%s and model=%s', (prop, self2._name)) res = cr.fetchone() self.field_id = res and res[0] return self.field_id
7361d410cefc08e39f421aa1e054c2ad659dca1e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/7361d410cefc08e39f421aa1e054c2ad659dca1e/fields.py
q = """SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='%s' AND a.attname='%s' AND c.oid=a.attrelid AND a.atttypid=t.oid""" % (self._table, k)
q = """SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='%s' AND a.attname='%s' AND c.oid=a.attrelid AND a.atttypid=t.oid""" % (self._table, k.lower())
def _auto_init(self, cr):
e16892125bb30199beae037b390dbcb59e3d3220 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/e16892125bb30199beae037b390dbcb59e3d3220/orm.py
break
continue
for state_name, state_def in obj.states.iteritems(): if 'result' in state_def: result = state_def['result'] if result['type'] != 'form': break
e655fa851f3d7553757cb5b47bd319e4e7b6e0a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/e655fa851f3d7553757cb5b47bd319e4e7b6e0a6/translate.py
(opj('lib','python%s' % py_short_version, 'site-package', 'tinyerp-server', 'i18n'),
(opj('lib','python%s' % py_short_version, 'site-packagess', 'tinyerp-server', 'i18n'),
def data_files(): '''Build list of data files to be installed''' files = [(opj('share', 'man', 'man1'), ['man/tinyerp-server.1']), (opj('share', 'man', 'man5'), ['man/terp_serverrc.5']), (opj('share','doc', 'tinyerp-server-%s' % version), [f for f in glob.glob('doc/*') if os.path.isfile(f)]), (opj('lib','python%s' % py_short_version, 'site-package', 'tinyerp-server', 'i18n'), glob.glob('bin/i18n/*')), (opj('lib', 'python%s' % py_short_version, 'site-packages', 'tinyerp-server', 'addons', 'custom'), glob.glob('bin/addons/custom/*xml') + glob.glob('bin/addons/custom/*rml') + glob.glob('bin/addons/custom/*xsl'))] for addon in find_addons(): add_path = addon.replace('.', os.path.sep).replace('tinyerp-server', 'bin', 1) pathfiles = [(opj('lib', 'python%s' % py_short_version, 'site-packages', add_path.replace('bin', 'tinyerp-server', 1)), glob.glob(opj(add_path, '*xml')) + glob.glob(opj(add_path, '*csv')) + glob.glob(opj(add_path, '*sql'))), (opj('lib', 'python%s' % py_short_version, 'site-packages', add_path.replace('bin', 'tinyerp-server', 1), 'data'), glob.glob(opj(add_path, 'data', '*xml'))), (opj('lib', 'python%s' % py_short_version, 'site-packages', add_path.replace('bin', 'tinyerp-server', 1), 'report'), glob.glob(opj(add_path, 'report', '*xml')) + glob.glob(opj(add_path, 'report', '*rml')) + glob.glob(opj(add_path, 'report', '*xsl')))] files.extend(pathfiles) return files
8fbfdcc407cb826e45e736571136c2830eae700d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/8fbfdcc407cb826e45e736571136c2830eae700d/setup.py
sequence_semaphore = threading.Semaphore()
def _code_get(self, cr, uid, context={}): cr.execute('select code, name from ir_sequence_type') return cr.fetchall()
26ccfdf34d69db923397793a5164265937fce0b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/26ccfdf34d69db923397793a5164265937fce0b8/ir_sequence.py
self.sequence_semaphore.acquire() cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True', (sequence_id,)) res = cr.dictfetchone() if res: cr.execute('update ir_sequence set number_next=number_next+number_increment where id=%d and active=True', (res['id'],)) self.sequence_semaphore.release() if res['number_next']: return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix']) else: return self._process(res['prefix']) + self._process(res['suffix']) else: self.sequence_semaphore.release()
try: cr.execute('lock table ir_sequence') cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True', (sequence_id,)) res = cr.dictfetchone() if res: cr.execute('update ir_sequence set number_next=number_next+number_increment where id=%d and active=True', (res['id'],)) if res['number_next']: return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix']) else: return self._process(res['prefix']) + self._process(res['suffix']) cr.commit() except: cr.rollback() return False
def get_id(self, cr, uid, sequence_id, test='id=%d'): self.sequence_semaphore.acquire() cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True', (sequence_id,)) res = cr.dictfetchone() if res: cr.execute('update ir_sequence set number_next=number_next+number_increment where id=%d and active=True', (res['id'],)) self.sequence_semaphore.release() if res['number_next']: return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix']) else: return self._process(res['prefix']) + self._process(res['suffix']) else: self.sequence_semaphore.release() return False
26ccfdf34d69db923397793a5164265937fce0b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/26ccfdf34d69db923397793a5164265937fce0b8/ir_sequence.py
def set(self, cr, uid, code, next_number): self.sequence_semaphore.acquire() cr.execute('update ir_sequence set number_next=%d where code=%s and active=True', (next_number, code,)) self.sequence_semaphore.release() return True
def get(self, cr, uid, code): return self.get_id(cr, uid, code, test='code=%s')
26ccfdf34d69db923397793a5164265937fce0b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/26ccfdf34d69db923397793a5164265937fce0b8/ir_sequence.py
self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo})
if module.state=='uninstalled': self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo})
def state_change(self, cr, uid, ids, newstate, context={}, level=50): if level<1: raise 'Recursion error in modules dependencies !' demo = True for module in self.browse(cr, uid, ids): mdemo = True for dep in module.dependencies_id: ids2 = self.search(cr, uid, [('name','=',dep.name)]) mdemo = mdemo and self.state_change(cr, uid, ids2, newstate, context, level-1) if not module.dependencies_id: mdemo = module.demo self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo}) demo = demo and mdemo return demo
71e1305eee7782e62b8f694a6f5eb7b6d385672d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/71e1305eee7782e62b8f694a6f5eb7b6d385672d/module.py
ids_dest = []
demo = True
def state_change(self, cr, uid, ids, newstate, context={}, level=50): if level<1: raise 'Recursion error in modules dependencies !' ids_dest = [] for module in self.browse(cr, uid, ids): for dep in module.dependencies_id: ids2 = self.search(cr, uid, [('name','=',dep.name)]) for id in ids2: if (id not in ids_dest): ids_dest.append(id) if module.state=='uninstalled': self.write(cr, uid, [module.id], {'state': newstate}) if ids_dest: self.state_change(cr, uid, ids_dest, newstate, context, level-1)
645b23c57702b08dff8279cd3ad4049ef07cc9fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/645b23c57702b08dff8279cd3ad4049ef07cc9fb/module.py
for id in ids2: if (id not in ids_dest): ids_dest.append(id) if module.state=='uninstalled': self.write(cr, uid, [module.id], {'state': newstate}) if ids_dest: self.state_change(cr, uid, ids_dest, newstate, context, level-1) for module in self.browse(cr, uid, ids): if module.state!='installed': demo=True for dep in module.dependencies_id: ids2 = self.search(cr, uid, [('name', '=', dep.name)]) for module2 in self.browse(cr, uid, ids2): demo = demo and module2.demo self.write(cr, uid, [module.id], {'demo':demo}) return True
mdemo = mdemo and self.state_change(cr, uid, ids2, newstate, context, level-1) if not module.dependencies_id: mdemo = module.demo self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo}) demo = demo and mdemo return demo
def state_change(self, cr, uid, ids, newstate, context={}, level=50): if level<1: raise 'Recursion error in modules dependencies !' ids_dest = [] for module in self.browse(cr, uid, ids): for dep in module.dependencies_id: ids2 = self.search(cr, uid, [('name','=',dep.name)]) for id in ids2: if (id not in ids_dest): ids_dest.append(id) if module.state=='uninstalled': self.write(cr, uid, [module.id], {'state': newstate}) if ids_dest: self.state_change(cr, uid, ids_dest, newstate, context, level-1)
645b23c57702b08dff8279cd3ad4049ef07cc9fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/645b23c57702b08dff8279cd3ad4049ef07cc9fb/module.py
self.write(cr, uid, ids, {'state': 'uninstalled'})
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
def button_install_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'uninstalled'}) return True
645b23c57702b08dff8279cd3ad4049ef07cc9fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/645b23c57702b08dff8279cd3ad4049ef07cc9fb/module.py
'iban': fields.char('Account number', size=64),
'iban': fields.char('Account Number', size=64),
def gen_next_ref(self, cr, uid, ids): if len(ids) != 1: return True # compute the next number ref cr.execute("select ref from res_partner where ref is not null order by char_length(ref) desc, ref desc limit 1") res = cr.dictfetchall() ref = res and res[0]['ref'] or '0' try: nextref = int(ref)+1 except e: raise osv.except_osv('Warning', "Couldn't generate the next id because some partners have an alphabetic id !")
85dc8f276458aefe78047117ec543f9d1fd81adc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/85dc8f276458aefe78047117ec543f9d1fd81adc/partner.py
def gen_next_ref(self, cr, uid, ids): if len(ids) != 1: return True # compute the next number ref cr.execute("select ref from res_partner where ref is not null order by char_length(ref) desc, ref desc limit 1") res = cr.dictfetchall() ref = res and res[0]['ref'] or '0' try: nextref = int(ref)+1 except e: raise osv.except_osv('Warning', "Couldn't generate the next id because some partners have an alphabetic id !")
85dc8f276458aefe78047117ec543f9d1fd81adc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12853/85dc8f276458aefe78047117ec543f9d1fd81adc/partner.py
return interface.implementedBy(obj)
return iter(interface.implementedBy(obj)).next()
def _get_interface(self, obj): try: if issubclass(obj, interface.Interface): return obj except: pass if callable(obj): return interface.implementedBy(obj) else: return interface.providedBy(obj)
353b24771e0396c239a2672e17ef1c22b2bf0d52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2278/353b24771e0396c239a2672e17ef1c22b2bf0d52/application.py
return interface.providedBy(obj)
return iter(interface.providedBy(obj)).next()
def _get_interface(self, obj): try: if issubclass(obj, interface.Interface): return obj except: pass if callable(obj): return interface.implementedBy(obj) else: return interface.providedBy(obj)
353b24771e0396c239a2672e17ef1c22b2bf0d52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2278/353b24771e0396c239a2672e17ef1c22b2bf0d52/application.py
cmd=['ssh','-oPreferredAuthentications=keyboard-interactive,password','-oNoHostAuthenticationForLocalhost=yes','-F/dev/null'] cmd+=['-l',login,'localhost']
cmd=['ssh'] cmd+=['-oPreferredAuthentications=keyboard-interactive,password'] cmd+=['-oNoHostAuthenticationForLocalhost=yes'] cmd+=['-oLogLevel=FATAL'] cmd+=['-F/dev/null','-l',login,'localhost']
def create(self,w=80,h=25): pid,fd=pty.fork() if pid==0: try: fdl=[int(i) for i in os.listdir('/proc/self/fd')] except OSError: fdl=range(256) for i in [i for i in fdl if i>2]: try: os.close(i) except OSError: pass if self.cmd: cmd=['/bin/sh','-c',self.cmd] elif os.getuid()==0: cmd=['/bin/login'] else: sys.stdout.write("Login: ") login=sys.stdin.readline().strip() if re.match('^[0-9A-Za-z-_.]+$',login): cmd=['ssh','-oPreferredAuthentications=keyboard-interactive,password','-oNoHostAuthenticationForLocalhost=yes','-F/dev/null'] cmd+=['-l',login,'localhost'] else: os._exit(0) env={} env["COLUMNS"]=str(w) env["LINES"]=str(h) env["TERM"]="linux" env["PATH"]=os.environ['PATH'] os.execvpe(cmd[0],cmd,env) else: fcntl.fcntl(fd, fcntl.F_SETFL, os.O_NONBLOCK) # python bug http://python.org/sf/1112949 on amd64 fcntl.ioctl(fd, struct.unpack('i',struct.pack('I',termios.TIOCSWINSZ))[0], struct.pack("HHHH",h,w,0,0)) self.proc[fd]={'pid':pid,'term':Terminal(w,h),'buf':'','time':time.time()} return fd
bb46bfd77130f0cc726ad5cc0238df29d33c9b37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/bb46bfd77130f0cc726ad5cc0238df29d33c9b37/ajaxterm.py
sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w')
nullin = file('/dev/null', 'r') nullout = file('/dev/null', 'w') os.dup2(nullin.fileno(), sys.stdin.fileno()) os.dup2(nullout.fileno(), sys.stdout.fileno()) os.dup2(nullout.fileno(), sys.stderr.fileno()) if os.getuid()==0 and o.uid: try: os.setuid(int(o.uid)) except: os.setuid(pwd.getpwnam(o.uid).pw_uid)
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm at http://localhost:%s/ pid: %d' % (o.port,pid) sys.exit(0) else: print 'AjaxTerm at http://localhost:%s/' % o.port at=AjaxTerm(o.cmd,o.index_file)
bb46bfd77130f0cc726ad5cc0238df29d33c9b37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/bb46bfd77130f0cc726ad5cc0238df29d33c9b37/ajaxterm.py
pid_file = '/var/run/ajaxterm.pid'
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm at http://localhost:%s/ pid: %d' % (o.port,pid) sys.exit(0) else: print 'AjaxTerm at http://localhost:%s/' % o.port at=AjaxTerm(o.cmd,o.index_file)
bb46bfd77130f0cc726ad5cc0238df29d33c9b37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/bb46bfd77130f0cc726ad5cc0238df29d33c9b37/ajaxterm.py
open(pid_file,'w+').write(str(pid)+'\n')
file(o.pidfile,'w+').write(str(pid)+'\n')
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm at http://localhost:%s/ pid: %d' % (o.port,pid) sys.exit(0) else: print 'AjaxTerm at http://localhost:%s/' % o.port at=AjaxTerm(o.cmd,o.index_file)
bb46bfd77130f0cc726ad5cc0238df29d33c9b37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/bb46bfd77130f0cc726ad5cc0238df29d33c9b37/ajaxterm.py
print 'Cannot store pid in %s' % pid_file
pass
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm at http://localhost:%s/ pid: %d' % (o.port,pid) sys.exit(0) else: print 'AjaxTerm at http://localhost:%s/' % o.port at=AjaxTerm(o.cmd,o.index_file)
bb46bfd77130f0cc726ad5cc0238df29d33c9b37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/bb46bfd77130f0cc726ad5cc0238df29d33c9b37/ajaxterm.py
if (t-t0)>3600:
if (t-t0)>120:
def proc_kill(self,fd): if fd in self.proc: self.proc[fd]['time']=0 t=time.time() for i in self.proc.keys(): t0=self.proc[i]['time'] if (t-t0)>3600: try: os.close(i) os.kill(self.proc[i]['pid'],signal.SIGTERM) except (IOError,OSError): pass del self.proc[i]
ee47be0f2054695e7e6d7e82ca8f47195820430f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/ee47be0f2054695e7e6d7e82ca8f47195820430f/ajaxterm.py
if i==0:
if i==0 or i==39 or i==49 or i==27:
def csi_m(self,l): for i in l: if i==0: self.sgr=0x000700 elif i>=30 and i<=37: c=i-30 self.sgr=(self.sgr&0xff00ff)|(c<<8) elif i>=40 and i<=47: c=i-40 self.sgr=(self.sgr&0x00ffff)|(c<<16)
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
self.sgr=(self.sgr&0xff00ff)|(c<<8)
self.sgr=(self.sgr&0xff08ff)|(c<<8)
def csi_m(self,l): for i in l: if i==0: self.sgr=0x000700 elif i>=30 and i<=37: c=i-30 self.sgr=(self.sgr&0xff00ff)|(c<<8) elif i>=40 and i<=47: c=i-40 self.sgr=(self.sgr&0x00ffff)|(c<<16)
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
def csi_m(self,l): for i in l: if i==0: self.sgr=0x000700 elif i>=30 and i<=37: c=i-30 self.sgr=(self.sgr&0xff00ff)|(c<<8) elif i>=40 and i<=47: c=i-40 self.sgr=(self.sgr&0x00ffff)|(c<<16)
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
def dumphtml(self):
def dumphtml(self,color=1):
def dumphtml(self): h=self.height w=self.width r="" span="" span_bg=-1 span_fg=-1 for i in range(h*w): q,c=divmod(self.scr[i],256) bg,fg=divmod(q,256) if i==self.cy*w+self.cx: bg=1 fg=7 if (bg!=span_bg or fg!=span_fg or i==h*w-1): if len(span): r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml))) span="" span_bg=bg span_fg=fg span+=chr(c) if i%w==w-1: span+='\n' r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r if self.last_html==r: return '<?xml version="1.0"?><idem></idem>' else: self.last_html=r
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
span_bg=-1 span_fg=-1
span_bg,span_fg=-1,-1
def dumphtml(self): h=self.height w=self.width r="" span="" span_bg=-1 span_fg=-1 for i in range(h*w): q,c=divmod(self.scr[i],256) bg,fg=divmod(q,256) if i==self.cy*w+self.cx: bg=1 fg=7 if (bg!=span_bg or fg!=span_fg or i==h*w-1): if len(span): r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml))) span="" span_bg=bg span_fg=fg span+=chr(c) if i%w==w-1: span+='\n' r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r if self.last_html==r: return '<?xml version="1.0"?><idem></idem>' else: self.last_html=r
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
bg,fg=divmod(q,256)
if color: bg,fg=divmod(q,256) else: bg,fg=0,7
def dumphtml(self): h=self.height w=self.width r="" span="" span_bg=-1 span_fg=-1 for i in range(h*w): q,c=divmod(self.scr[i],256) bg,fg=divmod(q,256) if i==self.cy*w+self.cx: bg=1 fg=7 if (bg!=span_bg or fg!=span_fg or i==h*w-1): if len(span): r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml))) span="" span_bg=bg span_fg=fg span+=chr(c) if i%w==w-1: span+='\n' r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r if self.last_html==r: return '<?xml version="1.0"?><idem></idem>' else: self.last_html=r
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
bg=1 fg=7
bg,fg=1,7
def dumphtml(self): h=self.height w=self.width r="" span="" span_bg=-1 span_fg=-1 for i in range(h*w): q,c=divmod(self.scr[i],256) bg,fg=divmod(q,256) if i==self.cy*w+self.cx: bg=1 fg=7 if (bg!=span_bg or fg!=span_fg or i==h*w-1): if len(span): r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml))) span="" span_bg=bg span_fg=fg span+=chr(c) if i%w==w-1: span+='\n' r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r if self.last_html==r: return '<?xml version="1.0"?><idem></idem>' else: self.last_html=r
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
span_bg=bg span_fg=fg
span_bg,span_fg=bg,fg
def dumphtml(self): h=self.height w=self.width r="" span="" span_bg=-1 span_fg=-1 for i in range(h*w): q,c=divmod(self.scr[i],256) bg,fg=divmod(q,256) if i==self.cy*w+self.cx: bg=1 fg=7 if (bg!=span_bg or fg!=span_fg or i==h*w-1): if len(span): r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml))) span="" span_bg=bg span_fg=fg span+=chr(c) if i%w==w-1: span+='\n' r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r if self.last_html==r: return '<?xml version="1.0"?><idem></idem>' else: self.last_html=r
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
def dump(self,fd):
def dump(self,fd,color=1):
def dump(self,fd): try: return self.proc[fd]['term'].dumphtml() except KeyError: return False
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
return self.proc[fd]['term'].dumphtml()
return self.proc[fd]['term'].dumphtml(color)
def dump(self,fd): try: return self.proc[fd]['term'].dumphtml() except KeyError: return False
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
dump=self.multi.dump(term)
dump=self.multi.dump(term,c)
def __call__(self, environ, start_response): req = qweb.QWebRequest(environ, start_response,session=None) if req.PATH_INFO.endswith('/u'): s=req.REQUEST["s"] k=req.REQUEST["k"] if s in self.session: term=self.session[s] else: term=self.session[s]=self.multi.create() if k: self.multi.proc_write(term,k) time.sleep(0.002) dump=self.multi.dump(term) req.response_headers['Content-Type']='text/xml' if isinstance(dump,str): req.write(dump) req.response_gzencode=1 else: del self.session[s] req.write('<?xml version="1.0"?><idem></idem>')
9006feef9ed1aece90fd903313a881c66d0a3c47 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/9006feef9ed1aece90fd903313a881c66d0a3c47/ajaxterm.py
fcntl.ioctl(fd, termios.TIOCSWINSZ , struct.pack("HHHH",h,w,0,0))
fcntl.ioctl(fd, struct.unpack('i',struct.pack('I',termios.TIOCSWINSZ))[0], struct.pack("HHHH",w,h,0,0))
def create(self,w=80,h=25): if self.cmd: cmd=['/bin/bash','-c',self.cmd] elif os.getuid()==0: cmd=['/bin/login'] else: cmd=['/usr/bin/ssh','-F/dev/null','-oPreferredAuthentications=password','-oNoHostAuthenticationForLocalhost=yes','localhost'] pid,fd=pty.fork() if pid==0: try: fdl=[int(i) for i in os.listdir('/proc/self/fd')] except OSError: fdl=range(256) for i in [i for i in fdl if i>2]: try: os.close(i) except OSError: pass env={} env["COLUMNS"]=str(w) env["LINES"]=str(h) env["TERM"]="linux" env["PATH"]=os.environ['PATH'] os.execve(cmd[0],cmd,env) else: fcntl.fcntl(fd, fcntl.F_SETFL, os.O_NONBLOCK) fcntl.ioctl(fd, termios.TIOCSWINSZ , struct.pack("HHHH",h,w,0,0)) self.proc[fd]={'pid':pid,'term':Terminal(w,h),'buf':'','time':time.time()} return fd
c6f48362e286b70d561c2a46038698263e893bfb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/c6f48362e286b70d561c2a46038698263e893bfb/ajaxterm.py
self.zipentry[zi.filename]=Entry(zi.filename,"file",self.zipmtime,zi.file_size)
if not zi.filename.endswith('/'): self.zipentry[zi.filename]=Entry(zi.filename,"file",self.zipmtime,zi.file_size)
def __init__(self, urlroot="/", zipname="",ziproot="/", listdir=1): StaticBase.__init__(self,urlroot,listdir) self.zipfile=zipfile.ZipFile(zipname) self.zipmtime=os.path.getmtime(zipname) self.ziproot=path_clean(ziproot) self.zipdir={} self.zipentry={}
f84de619110a259b4248d76650d24d96a59436d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/f84de619110a259b4248d76650d24d96a59436d0/static.py
fs_path=os.path.join(self.ziproot,path)
fs_path=os.path.join(self.ziproot,path).strip('/')
def fs_stat(self,path): fs_path=os.path.join(self.ziproot,path) if fs_path in self.zipentry: return self.zipentry[fs_path] elif fs_path in self.zipdir: return Entry(path,"dir",self.zipmtime,0) else: return None
f84de619110a259b4248d76650d24d96a59436d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/f84de619110a259b4248d76650d24d96a59436d0/static.py
fs_path = self.ziproot[1:]+path
fs_path = os.path.join(self.ziproot,path).strip('/')
def fs_getfile(self,path): fs_path = self.ziproot[1:]+path return self.zipfile.read(fs_path)
f84de619110a259b4248d76650d24d96a59436d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/f84de619110a259b4248d76650d24d96a59436d0/static.py
fs_path = self.ziproot[1:]+path
fs_path = os.path.join(self.ziproot,path).strip('/')
def fs_listdir(self,path): fs_path = self.ziproot[1:]+path return self.zipdir[fs_path].values()
f84de619110a259b4248d76650d24d96a59436d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/f84de619110a259b4248d76650d24d96a59436d0/static.py
"\x1b[?1c": None, "\x1b[?0c": None,
"\x1b[c": self.esc_da, "\x1b[0c": self.esc_da,
def init(self): self.esc_seq={ "\x00": None, "\x05": self.esc_da, "\x07": None, "\x08": self.esc_0x08, "\x09": self.esc_0x09, "\x0a": self.esc_0x0a, "\x0b": self.esc_0x0a, "\x0c": self.esc_0x0a, "\x0d": self.esc_0x0d, "\x0e": None, "\x0f": None, "\x1b#8": None, "\x1b=": None, "\x1b>": None, "\x1b(0": None, "\x1b(A": None, "\x1b(B": None, "\x1b[?1c": None, "\x1b[?0c": None, "\x1b]R": None, "\x1b7": self.esc_save, "\x1b8": self.esc_restore, "\x1bD": None, "\x1bE": None, "\x1bH": None, "\x1bM": self.esc_ri, "\x1bN": None, "\x1bO": None, "\x1bZ": self.esc_da, "\x1ba": None, "\x1bc": self.reset, "\x1bn": None, "\x1bo": None, } for k,v in self.esc_seq.items(): if v==None: self.esc_seq[k]=self.esc_ignore # regex d={ r'\[\??([0-9;]*)([@ABCDEFGHJKLMPXacdefghlmnqrstu`])' : self.csi_dispatch, r'\]([^\x07]+)\x07' : self.esc_ignore, } self.esc_re=[] for k,v in d.items(): self.esc_re.append((re.compile('\x1b'+k),v)) # define csi sequences self.csi_seq={ '@': (self.csi_at,[1]), '`': (self.csi_G,[1]), 'J': (self.csi_J,[0]), 'K': (self.csi_K,[0]), } for i in [i[4] for i in dir(self) if i.startswith('csi_') and len(i)==5]: if not self.csi_seq.has_key(i): self.csi_seq[i]=(getattr(self,'csi_'+i),[1]) # Init 0-256 to latin1 and html translation table self.trl1="" for i in range(256): if i<32: self.trl1+=" " elif i<127 or i>160: self.trl1+=chr(i) else: self.trl1+="?" self.trhtml="" for i in range(256): if i==0x0a or (i>32 and i<127) or i>160: self.trhtml+=chr(i) elif i<=32: self.trhtml+="\xa0" else: self.trhtml+="?"
a0defa78229e6a90151e2677e6b80236d573b921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/a0defa78229e6a90151e2677e6b80236d573b921/ajaxterm.py
self.esc_da(0)
pass
def csi_c(self,l): self.esc_da(0)
a0defa78229e6a90151e2677e6b80236d573b921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/a0defa78229e6a90151e2677e6b80236d573b921/ajaxterm.py
print 'AjaxTerm serving at http://localhost:%s/'%o.port
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() print 'AjaxTerm serving at http://localhost:%s/'%o.port if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm running with pid: %d' % pid sys.exit(0) at=AjaxTerm(o.cmd,o.index_file)
d1babae662f71a1951464c1659c2cb5de814f952 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/d1babae662f71a1951464c1659c2cb5de814f952/ajaxterm.py
print 'AjaxTerm running with pid: %d' % pid
print 'AjaxTerm at http://localhost:%s/ pid: %d' % (o.port,pid)
def main(): parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="port", default="8022", help="Set the TCP port (default: 8022)") parser.add_option("-c", "--command", dest="cmd", default=None,help="set the command (default: /bin/login or ssh localhost)") parser.add_option("-l", "--log", action="store_true", dest="log",default=0,help="log requests to stderr (default: quiet mode)") parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=0, help="run as daemon in the background") parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)") (o, a) = parser.parse_args() print 'AjaxTerm serving at http://localhost:%s/'%o.port if o.daemon: pid=os.fork() if pid == 0: #os.setsid() ? os.setpgrp() sys.stdin = open('/dev/null', 'r') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') else: pid_file = '/var/run/ajaxterm.pid' try: open(pid_file,'w+').write(str(pid)+'\n') except: print 'Cannot store pid in %s' % pid_file print 'AjaxTerm running with pid: %d' % pid sys.exit(0) at=AjaxTerm(o.cmd,o.index_file)
d1babae662f71a1951464c1659c2cb5de814f952 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/13009/d1babae662f71a1951464c1659c2cb5de814f952/ajaxterm.py
compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").read().strip('\n').split() if compileRecipeDirs :
compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in \"${compileRecipeDirs[@]}\"; do echo $i; done'").read().strip('\n').split('\n') if compileRecipeDirs and compileRecipeDirs[0] :
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].strip('\n').split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").read().strip('\n').split() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].strip('\n').split('\n') except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").read().strip('\n').split() if getRecipeStores : break #import sys #sys.stderr.write(str(compileRecipeDirs)) #sys.stderr.write(str(getRecipeStores)) import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
d46fce0d0456fb0937bfbefc4c875cdd88708921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/d46fce0d0456fb0937bfbefc4c875cdd88708921/PythonUtils.py
getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").read().strip('\n').split() if getRecipeStores :
getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in \"${getRecipeStores[@]}\"; do echo $i; done'").read().strip('\n').split('\n') if getRecipeStores and getRecipeStores[0] :
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].strip('\n').split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").read().strip('\n').split() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].strip('\n').split('\n') except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").read().strip('\n').split() if getRecipeStores : break #import sys #sys.stderr.write(str(compileRecipeDirs)) #sys.stderr.write(str(getRecipeStores)) import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
d46fce0d0456fb0937bfbefc4c875cdd88708921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/d46fce0d0456fb0937bfbefc4c875cdd88708921/PythonUtils.py
return (v+'-'+r).strip('-')
if r : return v+'-'+r else : return v
def Join_Version_Revision(v, r) : return (v+'-'+r).strip('-')
68f4d60c7fd16b0ff2134d9e1da72fbe118c270e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/68f4d60c7fd16b0ff2134d9e1da72fbe118c270e/PythonUtils.py
os.environ[name] = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; echo -n $"+name+"'").read()
os.environ[name] = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${"+name+"[@]}; do echo $i; done'").read().strip('\n')
def getGoboVariable(name, filename = 'GoboPath', isList = False) : if filename != 'GoboPath' : goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboScriptsDefaults = goboPrograms+'/Scripts/Current/Resources/Defaults/Settings/' goboManagerDefaults = goboPrograms+'/Manager/Current/Resources/Defaults/Settings/' files = [ "~/.Settings/"+filename, goboSettings + "/"+filename, goboScriptsDefaults + "/"+filename, goboManagerDefaults+"/"+filename, filename] else : files = [ filename] if not isList : try : return os.environ[name] except : for file in files : value = os.popen('. '+file+' 2> /dev/null; echo -n $'+name).read() if value : break os.environ[name] = value return value else : try : return os.environ[name].split() except : for file in files : os.environ[name] = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; echo -n $"+name+"'").read() if os.environ[name] : break return os.environ[name].split()
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
compileRecipeDirs = os.environ['compileRecipeDirs'].split()
compileRecipeDirs = os.environ['compileRecipeDirs'].strip('\n').split()
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].split() except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines() if getRecipeStores : break import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines()
compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").read().strip('\n').split()
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].split() except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines() if getRecipeStores : break import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
getRecipeStores = os.environ['getRecipeStores'].split()
getRecipeStores = os.environ['getRecipeStores'].strip('\n').split('\n')
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].split() except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines() if getRecipeStores : break import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines()
getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").read().strip('\n').split()
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].split() except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines() if getRecipeStores : break import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
def getCompileOptions() : import os goboSettings = getGoboVariable('goboSettings') goboPrograms = getGoboVariable('goboPrograms') goboCompileDefaults = goboPrograms+'/Compile/Current/Resources/Defaults/Settings/' compileSettingsFiles = [ "~/.Settings/Compile/Compile.conf", goboSettings + "/Compile/Compile.conf", goboCompileDefaults+"/Compile/Compile.conf" ] try : compileRecipeDirs = os.environ['compileRecipeDirs'].split() except : for file in compileSettingsFiles : compileRecipeDirs = os.popen("/bin/sh -c '. " +file+" 2> /dev/null; for i in ${compileRecipeDirs[@]}; do echo $i; done'").readlines() if compileRecipeDirs : break try : getRecipeStores = os.environ['getRecipeStores'].split() except : for file in compileSettingsFiles : getRecipeStores = os.popen("/bin/sh -c '. " + file +" 2> /dev/null; for i in ${getRecipeStores[@]}; do echo $i; done'").readlines() if getRecipeStores : break import os.path return (map(os.path.expanduser,compileRecipeDirs), getRecipeStores)
e913be36383005c3b2c4b3f4ba5a327c4ea5bff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/5186/e913be36383005c3b2c4b3f4ba5a327c4ea5bff5/PythonUtils.py
def controller_scan(directory):
def controller_scan(directory=None):
def controller_scan(directory): """ Scan a directory for python files and use them as controllers """ def find_controllers(dirname, prefix=''): controllers = [] for fname in os.listdir(dirname): filename = os.path.join(dirname, fname) if os.path.isfile(filename) and re.match('^[^_]{1,1}.*\.py$', fname): controllers.append(prefix + fname[:-3]) elif os.path.isdir(filename): controllers.extend(find_controllers(filename, prefix=prefix+fname+'/')) return controllers def longest_first(a, b): return cmp(len(b), len(a)) controllers = find_controllers(directory) controllers.sort(longest_first) return controllers
17852673013dc8f7e611d644472e67fe0b9a49ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/17852673013dc8f7e611d644472e67fe0b9a49ff/util.py
(reg, gaps) = self.buildnextreg(self.routelist, clist) print reg
(reg, noreqs, allblank) = self.buildnextreg(self.routelist, clist)
def makeregexp(self, clist): """ Create a regular expression for matching purposes, this MUST be called before match can function properly. clist should be a list of valid controller strings that can be matched, for this reason makeregexp should be called by the web framework after it knows all available controllers that can be utilized """ (reg, gaps) = self.buildnextreg(self.routelist, clist) print reg if not reg: reg = '/' reg = '^' + reg + '$' self.regexp = reg self.regmatch = re.compile(reg)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
default = '[^/]+'
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
(rest, moregaps) = ('', False)
(rest, noreqs, allblank) = ('', True, True)
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
(rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False
(rest, noreqs, allblank) = self.buildnextreg(path[1:], clist)
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?'
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
gaps = True
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
gaps = True
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?'
partreg = '(?P<' + var + '>[^/]+)' if self.reqs.has_key(var): noreqs = False if noreqs: if self.reqs.has_key(var) and self.defaults.has_key(var): reg = '(/' + partreg + rest + ')?' elif self.reqs.has_key(var): allblank = False reg = '(/' + partreg + ')' + rest elif self.defaults.has_key(var): reg = '(/' + partreg + ')?' + rest else: allblank = False reg = '(/' + partreg + ')' + rest
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
reg = '/' + partreg
if allblank and self.defaults.has_key(var): reg = '(/' + partreg + rest + ')?' else: reg = '/' + partreg + rest
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
reg = '(/' + '(?P<' + var + '>.*))*'
reg = '(/' + '(?P<' + var + '>.*))*' + rest
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
noreqs = False allblank = False reg = '/' + part + rest return (reg, noreqs, allblank)
def buildnextreg(self, path, clist): default = '[^/]+' part = path[0] reg = '' (rest, moregaps) = ('', False) if len(path[1:]) > 0: (rest, moregaps) = self.buildnextreg(path[1:], clist) gaps = False if part.startswith(':'): var = part[1:] partreg = '' if self.reqs.has_key(var) and self.defaults.has_key(var) and not moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')?' reg = reg + rest elif self.reqs.has_key(var) and self.defaults.has_key(var) and moregaps: gaps = True reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + rest elif self.reqs.has_key(var) and not self.defaults.has_key(var) and moregaps: reg = '(/(?P<' + var + '>' + self.reqs[var] + ')' reg = reg + '(' + rest + ')?' if self.reqs.has_key(var): gaps = True partreg = '(?P<' + var + '>' + self.reqs[var] + ')' elif var == 'controller': gaps = True partreg = '(?P<' + var + '>' + '|'.join(clist) + ')' else: partreg = '(?P<' + var + '>' + default + ')' if self.defaults.has_key(var) and not moregaps: reg = '(/' + partreg + ')?' else: reg = '/' + partreg elif part.startswith('*'): var = part[1:] reg = '(/' + '(?P<' + var + '>.*))*' else: gaps = True reg = '/' + part if moregaps and gaps: reg = '(' + reg + rest + ')?' else: reg = reg + rest return (reg, gaps)
d81bae157cb6d2bb0c6c006f5ed0836b19d297a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/d81bae157cb6d2bb0c6c006f5ed0836b19d297a3/base.py
if environ.get('SERVER_PORT', 80) != 80: self.__shared_state.host += ':' + environ['SERVER_PORT']
self.__shared_state.host += port_info
def load_wsgi_environ(self, environ): """ Load the protocol/server info from the environ and store it. Also, match the incoming URL if there's already a mapper, and store the resulting match dict in mapper_dict. """ if environ.get('HTTPS'): self.__shared_state.protocol = 'https' else: self.__shared_state.protocol = 'http' if hasattr(self, 'mapper'): self.mapper.environ = environ if 'PATH_INFO' in environ and hasattr(self, 'mapper'): mapper = self.mapper path = environ['PATH_INFO'] self.__shared_state.mapper_dict = mapper.match(path) host = environ.get('HTTP_HOST') or environ.get('SERVER_NAME') self.__shared_state.host = host.split(':')[0] if environ.get('SERVER_PORT', 80) != 80: self.__shared_state.host += ':' + environ['SERVER_PORT']
c77e5d08759788cfa307eaa143e44a445cea801b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/c77e5d08759788cfa307eaa143e44a445cea801b/__init__.py
primary = (method != 'GET' and lst.pop(0)) or None
if method not in ['POST', 'GET', 'any']: primary = lst.pop(0) else: primary = None
def requirements_for(meth): """Returns a new dict to be used for all route creation as the route options""" opts = options.copy() if method != 'any': opts['conditions'] = {'method':[meth]} return opts
31b71a664a34f649b1ec2d6a0bdb62b44b668467 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/31b71a664a34f649b1ec2d6a0bdb62b44b668467/base.py
return self.not_found(environ, start_response)
match = {}
def __call__(self, environ, start_response): config = request_config() config.mapper = self.mapper old_method = None if self.use_method_override: req = WSGIRequest(environ) if '_method' in environ.get('QUERY_STRING', '') and '_method' in req.GET: old_method = environ['REQUEST_METHOD'] environ['REQUEST_METHOD'] = req.GET['_method'] elif environ['REQUEST_METHOD'] == 'POST' and '_method' in req.POST: old_method = environ['REQUEST_METHOD'] environ['REQUEST_METHOD'] = req.POST['_method'] config.environ = environ match = config.mapper_dict if old_method: environ['REQUEST_METHOD'] = old_method if not match: return self.not_found(environ, start_response) for k,v in match.iteritems(): if v: match[k] = urllib.unquote_plus(v) environ['wsgiorg.routing_args'] = ((), match)
85dba5c21d94b2ed6fe4ce2a5a0e1395ad4007c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/85dba5c21d94b2ed6fe4ce2a5a0e1395ad4007c6/middleware.py
def not_found(self, environ, start_response): start_response('404 Not Found', [('Content-type', 'text/plain')]) return ['Not found']
def __call__(self, environ, start_response): config = request_config() config.mapper = self.mapper old_method = None if self.use_method_override: req = WSGIRequest(environ) if '_method' in environ.get('QUERY_STRING', '') and '_method' in req.GET: old_method = environ['REQUEST_METHOD'] environ['REQUEST_METHOD'] = req.GET['_method'] elif environ['REQUEST_METHOD'] == 'POST' and '_method' in req.POST: old_method = environ['REQUEST_METHOD'] environ['REQUEST_METHOD'] = req.POST['_method'] config.environ = environ match = config.mapper_dict if old_method: environ['REQUEST_METHOD'] = old_method if not match: return self.not_found(environ, start_response) for k,v in match.iteritems(): if v: match[k] = urllib.unquote_plus(v) environ['wsgiorg.routing_args'] = ((), match)
85dba5c21d94b2ed6fe4ce2a5a0e1395ad4007c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/85dba5c21d94b2ed6fe4ce2a5a0e1395ad4007c6/middleware.py
self.conditions['method'] != environ.get('HTTP_METHOD'):
self.conditions['method'] != environ.get('REQUEST_METHOD'):
def match(self, url, environ=None): """Match a url to our regexp. While the regexp might match, this operation isn't guaranteed as there's other factors that can cause a match to fail even though the regexp succeeds (Default that was relied on wasn't given, requirement regexp doesn't pass, etc.). Therefore the calling function shouldn't assume this will return a valid dict, the other possible return is False if a match doesn't work out. """ # Static routes don't match, they generate only if self.static: return False if url.endswith('/') and len(url) > 1: url = url[:-1] m = self.regmatch.match(url) if not m: return False if not environ: environ = {} if self.conditions: if self.conditions.has_key('method') and \ self.conditions['method'] != environ.get('HTTP_METHOD'): return False matchdict = m.groupdict() result = {} extras = frozenset(self.defaults.keys()) - frozenset(matchdict.keys()) for key,val in matchdict.iteritems(): if not val and self.defaults.has_key(key) and self.defaults[key]: result[key] = self.defaults[key] else: result[key] = val for key in extras: result[key] = self.defaults[key] # If there's a function, call it with environ and expire if it # returns False if self.conditions and self.conditions.has_key('function') and \ not self.conditions['function'](environ, result): return False return result
857a922f8c462bbdb254daa98b21c913ce78d09d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/857a922f8c462bbdb254daa98b21c913ce78d09d/base.py
for key in self.reqs.keys(): if key not in matchdict.keys() or matchdict[key] is None: try: result[key] = self.defaults[key] except: return False else: value = matchdict[key] or (self.defaults.has_key(key) and self.defaults[key]) or '' if not re.compile('^' + self.reqs[key] + '$').match(value): return False
def match(self, url): """Match a url to our regexp. While the regexp might match, this operation isn't guaranteed as there's other factors that can cause a match to fail even though the regexp succeeds (Default that was relied on wasn't given, requirement regexp doesn't pass, etc.). Therefore the calling function shouldn't assume this will return a valid dict, the other possible return is False if a match doesn't work out. """ # Static routes don't match, they generate only if self.static: return False if url.endswith('/') and len(url) > 1: url = url[:-1] m = self.regmatch.match(url) if m: matchdict = m.groupdict() result = {} extras = frozenset(self.defaults.keys()) - frozenset(matchdict.keys()) for key in self.reqs.keys(): if key not in matchdict.keys() or matchdict[key] is None: try: result[key] = self.defaults[key] except: return False else: value = matchdict[key] or (self.defaults.has_key(key) and self.defaults[key]) or '' if not re.compile('^' + self.reqs[key] + '$').match(value): return False for key,val in matchdict.iteritems(): if not val and self.defaults.has_key(key) and self.defaults[key]: result[key] = self.defaults[key] else: result[key] = val for key in extras: result[key] = self.defaults[key] return result else: return False
9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827/base.py
if match: return (match, route) return None
if self.debug: matchlog.append(dict(route=route, regexp=bool(match))) if match: return (match, route, matchlog) return (None, None, matchlog)
def _match(self, url): """Internal Route matcher Matches a URL against a route, and returns a tuple of the match dict and the route object if a match is successfull, otherwise it returns empty. For internal use only. """ if not self._created_regs and self.controller_scan: self.create_regs() elif not self._created_regs: raise RouteException, "You must generate the regular expressions before matching." if self.always_scan: self.create_regs() for route in self.matchlist: if self.prefix: if re.match(self._regprefix, url): url = re.sub(self._regprefix, r'\1', url) else: continue match = route.match(url) if match: return (match, route) return None
9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827/base.py
if result:
if self.debug: return result[0], result[1], result[2] if result[0]:
def match(self, url): """Match a URL against against one of the routes contained. Will return None if no valid match is found. resultdict = m.match('/joe/sixpack') """ result = self._match(url) if result: return result[0] return None
9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827/base.py
if result:
if self.debug: return result[0], result[1], result[2] if result[0]:
def routematch(self, url): """Match a URL against against one of the routes contained. Will return None if no valid match is found, otherwise a result dict and a route object is returned. resultdict, route_obj = m.match('/joe/sixpack') """ result = self._match(url) if result: return result[0], result[1] return None
9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/9a22764f5fd66c9658b08c3e78d9fb0c5ef3a827/base.py
self.connect("formatted_" + route_name, "%s.:(format);%s")
self.connect("formatted_" + route_name, "%s.:(format);%s" % (collection_path, action))
def requirements_for(meth): """Returns a new dict to be used for all route creation as the route options""" opts = options.copy() if method != 'any': opts['conditions'] = {'method':[meth.upper()]} return opts
5e8cbbf7317f33a71e3467e0afcc27299fc8af2f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/5e8cbbf7317f33a71e3467e0afcc27299fc8af2f/base.py
controllers.sort(cmp=longest_first)
controllers.sort(longest_first)
def longest_first(a, b): return cmp(len(b), len(a))
b23e47aaed5f75703e808d07d3739bf1e3b10afc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/b23e47aaed5f75703e808d07d3739bf1e3b10afc/util.py
if environ.get('SERVER_PORT') != '80':
if environ.get('SERVER_PORT', '80') != '80':
def load_wsgi_environ(self, environ): """ Load the protocol/server info from the environ and store it. Also, match the incoming URL if there's already a mapper, and store the resulting match dict in mapper_dict. """ port_info = '' if environ.get('HTTPS'): self.__shared_state.protocol = 'https' if environ.get('SERVER_PORT') != '443': port_info += ':' + environ['SERVER_PORT'] else: self.__shared_state.protocol = 'http' if environ.get('SERVER_PORT') != '80': port_info += ':' + environ.get('SERVER_PORT', '80') if hasattr(self, 'mapper'): self.mapper.environ = environ if 'PATH_INFO' in environ and hasattr(self, 'mapper'): mapper = self.mapper path = environ['PATH_INFO'] self.__shared_state.mapper_dict = mapper.match(path) host = environ.get('HTTP_HOST') or environ.get('SERVER_NAME') self.__shared_state.host = host.split(':')[0] self.__shared_state.host += port_info
8c7211d4f3d3dbc7bf3a8a1114c50a04f091d89c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/8c7211d4f3d3dbc7bf3a8a1114c50a04f091d89c/__init__.py
if meth: kargs['_method'] = meth if meth not in self.conditions.get('method', [meth]): return False
if meth: kargs['_method'] = meth
def generate(self,**kargs): """Generate a URL from ourself given a set of keyword arguments Toss an exception if this set of keywords would cause a gap in the url. """ # Verify that our args pass any regexp requirements for key in self.reqs.keys(): val = kargs.get(key) if val and not self.req_regs[key].match(str(val)): return False # Verify that if we have a method arg, its in the method accept list. Also, method # will be changed to _method for route generation meth = kargs.pop('method', None) if meth: kargs['_method'] = meth if meth not in self.conditions.get('method', [meth]): return False routelist = self.routebackwards urllist = [] gaps = False for part in routelist: if isinstance(part, dict) and part['type'] == ':': arg = part['name'] # For efficiency, check these just once has_arg = kargs.has_key(arg) has_default = self.defaults.has_key(arg) # Determine if we can leave this part off # First check if the default exists and wasn't provided in the call (also no gaps) if has_default and not has_arg and not gaps: continue # Now check to see if there's a default and it matches the incoming call arg if (has_default and has_arg) and str(kargs[arg]) == str(self.defaults[arg]) and not gaps: continue # We need to pull the value to append, if the arg is None and we have a default, use that if has_arg and kargs[arg] is None and has_default and not gaps: continue # Otherwise if we do have an arg, use that elif has_arg: val = kargs[arg] elif has_default and self.defaults[arg] is not None: val = self.defaults[arg] # No arg at all? This won't work else: return False urllist.append(url_quote(val)) if has_arg: del kargs[arg] gaps = True elif isinstance(part, dict) and part['type'] == '*': arg = part['name'] kar = kargs.get(arg) if kar is not None: urllist.append(url_quote(kar)) gaps = True elif part.endswith('/'): if not gaps and part == '/': continue elif not gaps: urllist.append(part[:-1]) gaps = True else: gaps = True urllist.append(part) else: gaps = True urllist.append(part) urllist.reverse() url = ''.join(urllist) if not url.startswith('/'): url = '/' + url extras = frozenset(kargs.keys()) - self.maxkeys if extras: url += '?' url += urllib.urlencode([(key, kargs[key]) for key in extras if key != 'action' or key != 'controller']) return url
da7004651758a3ba73f50c2731e2b08ce10f1730 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/da7004651758a3ba73f50c2731e2b08ce10f1730/base.py
new_path = path_prefix + "/new" member_path = path_prefix + "/:id"
new_path = path + "/new" member_path = path + "/:(id)"
def swap(dct, newdct): for key, val in dct.iteritems(): newdct.setdefault(val, []).append(key) return newdct
da7004651758a3ba73f50c2731e2b08ce10f1730 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12081/da7004651758a3ba73f50c2731e2b08ce10f1730/base.py