rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
len=1
flen=1
def __init__(self, filename='', mode='r'): #mode is 'h' (headers) or 'r' (data+headers) self.filename=filename if mode=='h': #Mode h opens file, reads headers, closes the file self.data = None if not filename: self.headers={'SIMPLE':'T', 'EXTEND':'T', 'NAXIS':'2'} self.comments={'COMMENT':'Empty header','HISTO...
len=len*shape[-1]
flen=flen*shape[-1]
def __init__(self, filename='', mode='r'): #mode is 'h' (headers) or 'r' (data+headers) self.filename=filename if mode=='h': #Mode h opens file, reads headers, closes the file self.data = None if not filename: self.headers={'SIMPLE':'T', 'EXTEND':'T', 'NAXIS':'2'} self.comments={'COMMENT':'Empty header','HISTO...
len=len*2
flen=flen*2
def __init__(self, filename='', mode='r'): #mode is 'h' (headers) or 'r' (data+headers) self.filename=filename if mode=='h': #Mode h opens file, reads headers, closes the file self.data = None if not filename: self.headers={'SIMPLE':'T', 'EXTEND':'T', 'NAXIS':'2'} self.comments={'COMMENT':'Empty header','HISTO...
len=len*4
flen=flen*4
def __init__(self, filename='', mode='r'): #mode is 'h' (headers) or 'r' (data+headers) self.filename=filename if mode=='h': #Mode h opens file, reads headers, closes the file self.data = None if not filename: self.headers={'SIMPLE':'T', 'EXTEND':'T', 'NAXIS':'2'} self.comments={'COMMENT':'Empty header','HISTO...
self.data=fromstring(self.file.read(len),type).byteswapped().astype(Float64)
fraw = self.file.read(flen) if len(fraw) <> flen: print "Expected %d bytes, read %d bytes." % (flen, len(fraw)) return self.data=fromstring(fraw,type).byteswapped().astype(Float64)
def __init__(self, filename='', mode='r'): #mode is 'h' (headers) or 'r' (data+headers) self.filename=filename if mode=='h': #Mode h opens file, reads headers, closes the file self.data = None if not filename: self.headers={'SIMPLE':'T', 'EXTEND':'T', 'NAXIS':'2'} self.comments={'COMMENT':'Empty header','HISTO...
f.write(' ' * (2880*(f.tell()/2880+1)-f.tell()) )
f.write(' ' * (2880*((f.tell()-1)/2880+1)-f.tell()) )
def save(self, fname='/tmp/out.fits', bitpix=None): """Saves image to a given file name. The bitpix field has the same meaning as the FITS header BITPIX, ie 16 or 32 for signed integers, and -32 for 32-bit floating point. The BSCALE, BZERO, NAXIS1 and NAXIS2 cards are updated to fit the data. If bitpix is specified as ...
f.write('\0' * (2880*(f.tell()/2880+1)-f.tell()) )
f.write('\0' * (2880*((f.tell()-1)/2880+1)-f.tell()) )
def save(self, fname='/tmp/out.fits', bitpix=None): """Saves image to a given file name. The bitpix field has the same meaning as the FITS header BITPIX, ie 16 or 32 for signed integers, and -32 for 32-bit floating point. The BSCALE, BZERO, NAXIS1 and NAXIS2 cards are updated to fit the data. If bitpix is specified as ...
yg = str(yearguess)[-2:]
yg = int(str(yearguess)[-2:])
def getdate(s="", yearguess=None): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it over...
def getdate(s=""):
def getdate(s="", yearguess=None):
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
assert month, "Only two numbers and month name not found in '"+s+"'"
assert month, "Only two numbers, and month name not found in '"+s+"'"
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
if nums[0]>31:
if nums[0]>100: assert (nums[2]>=1) and (nums[2]<=mlen[month-1]) and (nums[0]>1980) and (nums[0]<2050), "YMD, Day invalid in '"+s+"'" day=nums[2] year=nums[0] return (year,month,day),1 if nums[2]>100: assert (nums[0]>=1) and (nums[0]<=mlen[month-1]) and (nums[2]>1980) and (nums[2]<2050), "DMY, Day invalid in '"+s+"'...
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
if nums[2]>31:
if nums[2]>50:
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
if (day>5) or (dateorder=='YMD'): return (year,month,day),0.5
if dateorder == 'YMD': return (year,month,day),0.5
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
if (day>5) or (dateorder=='DMY'): return (year,month,day),0.5
if dateorder == 'DMY': return (year,month,day),0.5
def getdate(s=""): """Attempt to parse the given string as a date. The format is unknown, but it's assumed that the broken American m/d/y isn't a possibility. It attempts to distinguish between d/m/y and y/m/d using the values, and handles any seperator. if dateorder (global) is 'DMY' or 'YMD', it overrides the last-r...
def parseheader(h=None,comments=None):
def parseheader(h=None,comments=None, yearguess=None):
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(DATEmOBSd)
date,c = getdate(DATEmOBSd, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(DATEmOBS)
date,c = getdate(DATEmOBS, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(DATEd)
date,c = getdate(DATEd, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(DATE)
date,c = getdate(DATE, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(UTDATE)
date,c = getdate(UTDATE, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
date,c = getdate(EPOCH)
date,c = getdate(EPOCH, yearguess)
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
exptimes.append((eq,"EXPTIME",100))
exptimes.append((et,"EXPTIME",100))
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
exptimes.append((eq,"EXPOSURE",100))
exptimes.append((et,"EXPOSURE",100))
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
exptimes.append((eq,"ITIME",90))
exptimes.append((et,"ITIME",90))
def parseheader(h=None,comments=None): """ parseheader returns lists of all values in each category (all dates, all ras, etc). Each list is composed of tuples, being (value, field, confidence), where value is the number, field is a string containing the name of the FITS header field it was derived from, and confidence ...
if (pid != 0 ):
if ( pid != None and pid != 0 ):
def _packageInDB(self, rpm_info): pid = self._getPackageId(rpm_info['name'], rpm_info['version'], rpm_info['release'], rpm_info['epoch']) if (pid != 0 ): self.cursor = self.conn.cursor() sql = """ select rpm_id from rpm where rpm.package_id = '%d' and rpm.arch = '%s'""" % (pid, rpm_info['arch']) self.cursor.execute(sql...
result = resultSet(self.cursor)
result = resultSet(self.cursor).dump()
def setupBaseChannels(self, pid): """Subscribe profile to all matching base channels."""
return resultr
return result
def poll_status(): result = {} result['checkin_interval'] = 15360 result['server_status'] = 'normal' return resultr
genpkgmetadata.main(["-q", pathname])
cache = os.path.join(self.config['current_dir'], "sha1cache") genpkgmetadata.main(["-c", cache, "-q", pathname])
def _yumMetaData(self, channel): log("Creating Yum Metadata", DEBUG) pathname = os.path.join(self.config['current_dir'], 'www', channel) genpkgmetadata.main(["-q", pathname])
name = header[RPM.RPMTAG_REQUIRENAME] flags = header[RPM.RPMTAG_REQUIREFLAGS] vers = header[RPM.RPMTAG_REQUIREVERSION]
name = header[RPM.REQUIRENAME] flags = header[RPM.REQUIREFLAGS] vers = header[RPM.REQUIREVERSION]
def _insertRequires(self, rpm_id, header): name = header[RPM.RPMTAG_REQUIRENAME] flags = header[RPM.RPMTAG_REQUIREFLAGS] vers = header[RPM.RPMTAG_REQUIREVERSION]
def _intertConflicts(self, rpm_id, header): name = header[RPM.RPMTAG_CONFLICTNAME] flags = header[RPM.RPMTAG_CONFLICTFLAGS] vers = header[RPM.RPMTAG_CONFLICTVERSION]
def _insertConflicts(self, rpm_id, header): name = header[RPM.CONFLICTNAME] flags = header[RPM.CONFLICTFLAGS] vers = header[RPM.CONFLICTVERSION]
def _intertConflicts(self, rpm_id, header): name = header[RPM.RPMTAG_CONFLICTNAME] flags = header[RPM.RPMTAG_CONFLICTFLAGS] vers = header[RPM.RPMTAG_CONFLICTVERSION]
where channel.name = '%s'""" %
where channel.label = '%s'""" %
def _setActiveElems(self, channel): # This is what sets which RPMS are active. I'tll be fun to diagnose... # First, get a list of unique pkg names: self.cursor.execute(""" select distinct on (pkgname) pkgname from package inner join rpm on (package.package_id = rpm.package_id) inner join channel on (channel.channel_id...
ts = rpm.TransactionSet("/", rpm._RPMVSF_NOSIGNATURES) fd = os.open(filename, os.O_RDONLY) hdr = ts.hdrFromFdno(fd) os.close(fd)
try: ts = rpm.TransactionSet("/", rpm._RPMVSF_NOSIGNATURES) fd = os.open(filename, os.O_RDONLY) hdr = ts.hdrFromFdno(fd) os.close(fd) except: logException() log ("Reading file - not an RPM?") return None if ( hdr == None ): return None
def _read41(self, filename): # First, suck in the header. ts = rpm.TransactionSet("/", rpm._RPMVSF_NOSIGNATURES) fd = os.open(filename, os.O_RDONLY) hdr = ts.hdrFromFdno(fd) os.close(fd) info = {} info['pathname'] = filename info['issrc'] = hdr[rpm.RPMTAG_SOURCEPACKAGE] info['size'] = str(os.stat(filename)[stat.ST_SIZE...
sql = """ select rpm_id from rpm where rpm.package_id = %d and rpm.arch = %s""" % (pid, rpm_info['arch'])
sql = """ select rpm_id from rpm where rpm.package_id = '%d' and rpm.arch = '%s'""" % (pid, rpm_info['arch'])
def _packageInDB(self, rpm_info): pid = self._getPackageId(rpm_info['name'], rpm_info['version'], rpm_info['release'], rpm_info['epoch']) if (pid != 0 ): self.cursor = self.conn.cursor() sql = """ select rpm_id from rpm where rpm.package_id = %d and rpm.arch = %s""" % (pid, rpm_info['arch']) self.cursor.execute(sql) re...
log("Adding RPM %s to channel %s" % (path, channel), TRIVIA)
def _addRpmPackage(self, config, path, channel): log("Adding RPM %s to channel %s" % (path, channel), TRIVIA) self.cursor = self.conn.cursor() filename = os.path.basename(path) rpm_info = self.rpmWrapper.getRpmInfo(path)
os.symlink(row[0], dir)
try: os.symlink(row[0], dir) except OSError, error: log("OS Error number %s occurred - why?" % error, DEBUG)
def _populateChannelDirs(self, config, channel): logfunc(locals(), DEBUG2) results = {} self.cursor.execute("""select lastupdate from channel where channel.label = '%s'""" % (channel,) ) qry = self.cursor.fetchall() # Should only be one channel... assert ( len(qry) == 1) updatefilename = qry[0][0]
chan_dir = os.path.join(webdir, channel['name'])
chan_dir = os.path.join(webdir, channel['label'])
def makeChannel(self, config, channel): logfunc(locals(), TRACE) self.cursor = self.conn.cursor()
log("Channel dirs populated), DEBUG2)
log("Channel dirs populated", DEBUG2)
def scanChannel(self, config, channel): # This would be a good place to drop the indexes... then recreate them # when we're all done. We don't do that yet. result = {} logfunc(locals(), TRACE) self.cursor = self.conn.cursor() # Update the channel modification time FIRST. self.cursor.execute("""update channel set last...
if ( os.isdir(pathname) ):
if ( os.path.isdir(pathname) ):
def _scanDirToChannel(self, config, channel, dir): result = 1 log("scanning directory %s" % (dir,) ) for file in os.listdir(dir): pathname = os.path.join(dir, file) if ( os.isdir(pathname) ): result = result and (0 != self._scanDirToChannel(config, channel, pathname) ) if ( os.isfile(pathname) ): result = result and ( ...
if ( os.isfile(pathname) ):
if ( os.path.isfile(pathname) ):
def _scanDirToChannel(self, config, channel, dir): result = 1 log("scanning directory %s" % (dir,) ) for file in os.listdir(dir): pathname = os.path.join(dir, file) if ( os.isdir(pathname) ): result = result and (0 != self._scanDirToChannel(config, channel, pathname) ) if ( os.isfile(pathname) ): result = result and ( ...
if ( is.isfile(pathname) ):
if ( os.isfile(pathname) ):
def _scanDirToChannel(self, config, channel, dir): result = 1 log("scanning directory %s" % (dir,) ) for file in os.listdir(dir): pathname = os.path.join(dir, file) if ( os.isdir(pathname) ): result = result and (0 != self._scanDirToChannel(config, channel, pathname) ) if ( is.isfile(pathname) ): result = result and ( ...
(self.pkc_version, orig_version)
(pkc_version, orig_version)
def pkgc_version_check(name, longname, req_version): is_installed = not os.system('pkg-config --exists %s' % name) if not is_installed: print "Could not find %s" % longname return 0 orig_version = getoutput('pkg-config --modversion %s' % name) version = map(int, orig_version.split('.')) pkc_version = map(int, req_vers...
self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-4])
if os.name == "nt": self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-3]) else: self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-4])
def prepare(self): self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-4]) self.exec_prefix = os.path.join(self.prefix, 'bin') self.includedir = os.path.join(self.prefix, 'include') self.libdir = os.path.join(self.prefix, 'lib') self.datadir = os.path.join(self.prefix, 'share') self.add_template_option('prefix'...
self.failUnless(isinstance(obj, Object2)) self.assertEqual(obj.__gtype__.name, 'Object2')
def testSubSubType(self): Object1 = type('Object1', (gobject.GObject,), {'__gtype_name__': 'Object1'}) Object2 = type('Object2', (Object1,), {'__gtype_name__': 'Object2'})
def _test_bug375589(self): class A: def callback(self, o): o.handler_block_by_func(self.callback) e = E() e.connect("signal", A().callback) e.emit('signal') gc.collect()
def _test_bug375589(self): class A: def callback(self, o): o.handler_block_by_func(self.callback)
class MyObject(gobject.GObject): __gtype_name__ = 'MyObject' class TypeNameTest(unittest.TestCase): def testTypeName(self): self.assertEqual(gobject.type_name(MyObject), 'MyObject')
def testObject(self): self.checkType(gobject.TYPE_OBJECT, 'PyObject')
def pkgc_version_check(name, longname, req_version): is_installed = not os.system('pkg-config --exists %s' % name) if not is_installed: print "Could not find %s" % longname return 0 orig_version = getoutput('pkg-config --modversion %s' % name) version = map(int, orig_version.split('.')) pkc_version = map(int, req_vers...
def pkgc_version_check(name, longname, req_version): is_installed = not os.system('pkg-config --exists %s' % name) if not is_installed: print "Could not find %s" % longname return 0 orig_version = getoutput('pkg-config --modversion %s' % name) version = map(int, orig_version.split('.')) pkc_version = map(int, req_vers...
class BuildExt(build_ext): def build_extension(self, ext): if hasattr(ext, 'generate'): ext.generate() build_ext.build_extension(self, ext) def list_files(dir): """List all files in a dir, with filename match support: for example: glade/*.glade will return all files in the glade directory that matches *.glade. It als...
def generate(self): map(lambda x: x.generate(), self.templates)
def testGObjectInvalidSignalOverride(self): class Foo(gobject.GObject): __gsignals__ = {} __gsignals__['monkey'] = 'override' self.assertRaises(TypeError, gobject.type_register, Foo)
def testObject(self): self.checkType(gobject.TYPE_OBJECT, 'PyObject')
self.exec_prefix = os.path.join(self.prefix, 'bin') self.includedir = os.path.join(self.prefix, 'include') self.libdir = os.path.join(self.prefix, 'lib') self.datadir = os.path.join(self.prefix, 'share')
self.exec_prefix = '${prefix}/bin' self.includedir = '${prefix}/include' self.libdir = '${prefix}/lib' self.datadir = '${prefix}/share'
def prepare(self): if os.name == "nt": self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-3]) else: # default: os.name == "posix" self.prefix = os.sep.join(self.install_dir.split(os.sep)[:-4]) self.exec_prefix = os.path.join(self.prefix, 'bin') self.includedir = os.path.join(self.prefix, 'include') self.libdir...
self.template_options['@%s@'] = value
self.template_options['@%s@' % name] = value
def add_template_option(self, name, value): self.template_options['@%s@'] = value
def testUnicharArg(self): """ Test unichar values when used as arguments. """
def testUnicharArg(self): """ Test unichar values when used as arguments. """ entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_invisible_char(valid_value) self.assertEqual(entry.get_invisible_char(), unicode(valid_value), valid_value)
def testUnicharArg(self): """ Test unichar values when used as arguments. """
entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_invisible_char(valid_value) assert entry.get_invisible_char() == unicode(valid_value)
for invalid_value in ('12', None, 1, ''): try: entry.set_invisible_char(invalid_value) except: pass else: raise AssertionError( 'exception not raised on invalid value w/ ' 'set_invisible_char: %s' % invalid_value)
def testUnicharArg(self): """ Test unichar values when used as arguments. """
for invalid_value in ['12', None, 1, '']: try: entry.set_invisible_char(invalid_value) except: pass else: raise AssertionError('exception not raised on invalid value w/ set_invisible_char: %s' % invalid_value)
def testUnicharProperty(self): """ Test unichar values when used as properties. """
def testUnicharArg(self): """ Test unichar values when used as arguments. """
def testUnicharProperty(self): """ Test unichar values when used as properties. """
entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) self.assertEqual(entry.get_property('invisible_char'), valid_value, valid_value) for invalid_value in ('12', None, 1, ''): try: entry.set_property('invisible_char', invalid_value) except...
def testUnicharProperty(self): """ Test unichar values when used as properties. """ entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) assert entry.get_property('invisible_char') == valid_value
entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) assert entry.get_property('invisible_char') == valid_value
def testColorCreation(self): """ Test GdkColor creation """
def testUnicharProperty(self): """ Test unichar values when used as properties. """ entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) assert entry.get_property('invisible_char') == valid_value
for invalid_value in ['12', None, 1, '']: try: entry.set_property('invisible_char', invalid_value) except: pass else: raise AssertionError('exception not raised on invalid value w/ set_property: %s' % invalid_value)
c = gtk.gdk.Color(1, 2, 3) self.assertEqual(c.red, 1) self.assertEqual(c.green, 2) self.assertEqual(c.blue, 3)
def testUnicharProperty(self): """ Test unichar values when used as properties. """ entry = gtk.Entry() for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: entry.set_property('invisible_char', valid_value) assert entry.get_property('invisible_char') == valid_value
def testColorCreation(self): """ Test GdkColor creation """
c = gtk.gdk.Color(pixel=0xffff) self.assertEqual(c.pixel, 0xffff)
def testColorCreation(self): """ Test GdkColor creation """
c = gtk.gdk.Color(1, 2, 3) assert c.red == 1 and c.green == 2 and c.blue == 3
c = gtk.gdk.Color(pixel=0xffffL) self.assertEqual(c.pixel, 0xffff)
def testColorCreation(self): """ Test GdkColor creation """
c = gtk.gdk.Color(pixel = 0xffff) assert c.pixel == 0xffff c = gtk.gdk.Color(pixel = 0xffffL) assert c.pixel == 0xffff c = gtk.gdk.Color(pixel = 0xffffffffL) assert c.pixel == 0xffffffffL
c = gtk.gdk.Color(pixel=0xffffffffL) self.assertEqual(c.pixel, 0xffffffffL)
def testColorCreation(self): """ Test GdkColor creation """
class SigPropClass(gobject.GObject): __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_INT,)) } __gproperties__ = { 'foo': (str, None, None, '', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT), } signal_emission_failed = False def do_my_signal(self, arg): self.arg = arg def d...
def do_my_signal(self, data): self.data = data self.test.assertEqual(len(data), 3) return ''.join([data[2], data[1], data[0]])
def get_include_dirs(self, name): output = getoutput('pkg-config --cflags-only-I %s' % name) return output.replace('-I', '').split() def get_libraries(self, name): output = getoutput('pkg-config --libs-only-l %s' % name) return output.replace('-l', '').split() def get_library_dirs(self, name): output = getoutput('pkg...
def get_include_dirs(self, names): if type(names) != tuple: names = (names,) retval = [] for name in names: output = getoutput('pkg-config --cflags-only-I %s' % name) retval.extend(output.replace('-I', '').split()) return retval def get_libraries(self, names): if type(names) != tuple: names = (names,) retval = [] for ...
def get_include_dirs(self, name): output = getoutput('pkg-config --cflags-only-I %s' % name) return output.replace('-I', '').split()
retval = os.system('pkg-config --exists %s' % self.pkc_name) if retval: print ("* %s.pc could not be found, bindings for %s" " will not be built." % (self.pkc_name, self.name)) self.can_build_ok = 0 return 0 orig_version = getoutput('pkg-config --modversion %s' % self.pkc_name) version = map(int, orig_version.split('....
if type(self.pkc_name) != tuple: reqs = [(self.pkc_name, self.pkc_version)]
def can_build(self): """If the pkg-config version found is good enough""" if self.can_build_ok != None: return self.can_build_ok
print "Warning: Too old version of %s" % self.pkc_name print " Need %s, but %s is installed" % \ (self.pkc_version, orig_version) self.can_build_ok = 0 return 0
reqs = zip(self.pkc_name, self.pkc_version) for package, version in reqs: retval = os.system('pkg-config --exists %s' % package) if retval: print ("* %s.pc could not be found, bindings for %s" " will not be built." % (package, self.name)) self.can_build_ok = 0 return 0 orig_version = getoutput('pkg-config --modversio...
def can_build(self): """If the pkg-config version found is good enough""" if self.can_build_ok != None: return self.can_build_ok
class RadioToolButtonTest(RadioTest): widget_type = gtk.RadioToolButton
def newLabel(self, label): return gtk.RadioAction('RadioAction', label, '', '', 0)
def compareGroups(self, group1, group2): return cmp(map(id, group1), map(id, group2))
def compareGroups(self, group1, group2): # GtkRadioToolButton.set/get_groups return GtkRadioButtons, # so instead of doing a normal cmp, compare ids return cmp(map(id, group1), map(id, group2))
def newLabel(self, label): radio = gtk.RadioToolButton(None) radio.set_label(label) return radio
def newLabel(self, label): # We don't have a constructor for which we can pass in a label # for, so just call set_label instead radio = gtk.RadioToolButton(None) radio.set_label(label) return radio
self._uint64
self._uint64 = value
def do_set_property(self, pspec, value): if pspec.name == 'normal': self._value = value elif pspec.name == 'construct': self._construct = value elif pspec.name == 'construct-only': self._construct_only = value elif pspec.name == 'uint64': self._uint64 else: raise AssertionError
millis = mf.total_time() secs = millis / 1000 print "total time %d ms (%dm%2ds)" % (millis, secs / 60, secs % 60)
def play(file): mf = mad.MadFile(file) if mf.layer() == mad.LAYER_I: print "MPEG Layer I" elif mf.layer() == mad.LAYER_II: print "MPEG Layer II" elif mf.layer() == mad.LAYER_III: print "MPEG Layer III" else: print "unexpected layer value" if mf.mode() == mad.MODE_SINGLE_CHANNEL: print "single channel" elif mf.mode() ...
import sys, os.path
def play(file): mf = mad.MadFile(file) if mf.layer() == mad.LAYER_I: print "MPEG Layer I" elif mf.layer() == mad.LAYER_II: print "MPEG Layer II" elif mf.layer() == mad.LAYER_III: print "MPEG Layer III" else: print "unexpected layer value" if mf.mode() == mad.MODE_SINGLE_CHANNEL: print "single channel" elif mf.mode() ...
mad_include_dir = data['mad_include_dir'] mad_lib_dir = data['mad_lib_dir'] mad_libs = string.split(data['mad_libs'])
def get_setup(): data = {} r = re.compile(r'(\S+)\s*?=\s*?(.+)') if not os.path.isfile('Setup'): print "No 'Setup' file. Perhaps you need to run the configure script." sys.exit(1) f = open('Setup', 'r') for line in f.readlines(): m = r.search(line) if not m: print "Error in setup file:", line sys.exit(1) key = m.gro...
include_dirs=[mad_include_dir], library_dirs=[mad_lib_dir], libraries=mad_libs)
include_dirs=[data['mad_include_dir']], library_dirs=[data['mad_lib_dir']], libraries=string.split(data['mad_libs']))
def get_setup(): data = {} r = re.compile(r'(\S+)\s*?=\s*?(.+)') if not os.path.isfile('Setup'): print "No 'Setup' file. Perhaps you need to run the configure script." sys.exit(1) f = open('Setup', 'r') for line in f.readlines(): m = r.search(line) if not m: print "Error in setup file:", line sys.exit(1) key = m.gro...
packages = ['mad'], package_dir = {'mad' : 'src'}, ext_package = 'mad',
def get_setup(): data = {} r = re.compile(r'(\S+)\s*?=\s*?(.+)') if not os.path.isfile('Setup'): print "No 'Setup' file. Perhaps you need to run the configure script." sys.exit(1) f = open('Setup', 'r') for line in f.readlines(): m = r.search(line) if not m: print "Error in setup file:", line sys.exit(1) key = m.gro...
sources=['src/madmodule.c', 'src/pymadfile.c'],
sources=['src/madmodule.c', 'src/pymadfile.c', 'src/xing.c'],
def get_setup(): data = {} r = re.compile(r'(\S+)\s*=\s*(.+)') if not os.path.isfile('Setup'): print "No 'Setup' file. Perhaps you need to run the configure script." sys.exit(1) f = open('Setup', 'r') for line in f.readlines(): m = r.search(line) if not m: print "Error in setup file:", line sys.exit(1) key = m.group...
r = re.compile(r'(\S+)\s*?=\s*?(.+)')
r = re.compile(r'(\S+)\s*=\s*(.+)')
def get_setup(): data = {} r = re.compile(r'(\S+)\s*?=\s*?(.+)') if not os.path.isfile('Setup'): print "No 'Setup' file. Perhaps you need to run the configure script." sys.exit(1) f = open('Setup', 'r') for line in f.readlines(): m = r.search(line) if not m: print "Error in setup file:", line sys.exit(1) key = m.gro...
if i in (('Depends', 'Provides', 'Suggests', 'Recomends')):
if i in (('Depends', 'Provides', 'Suggests', 'Recommends')):
def process_package(in_entry, vars): e = entry() for i in in_entry.iterkeys(): if i in (('Depends', 'Provides', 'Suggests', 'Recomends')): process_depends(i, e, in_entry, vars) elif i == 'Description': process_description(e, in_entry, vars) elif i[:2] == 'X-': pass else: e[i] = substitute(in_entry[i], vars) return e
for i in (('Depends', 'Provides', 'Suggests', 'Recomends')):
for i in (('Depends', 'Provides', 'Suggests', 'Recommends')):
def process_real_image(in_entry, vars): in_entry = in_entry.copy() if vars.has_key('desc'): in_entry['Description'] += "\n.\n" + vars['desc'] entry = process_package(in_entry, vars) for i in (('Depends', 'Provides', 'Suggests', 'Recomends')): value = [] tmp = entry.get(i, None) if tmp: tmp = tmp.split(',') for t in tmp...
elif i == 'Recomends': t = vars.get('Recomends', None)
elif i == 'Recommends': t = vars.get('recommends', None)
def process_real_image(in_entry, vars): in_entry = in_entry.copy() if vars.has_key('desc'): in_entry['Description'] += "\n.\n" + vars['desc'] entry = process_package(in_entry, vars) for i in (('Depends', 'Provides', 'Suggests', 'Recomends')): value = [] tmp = entry.get(i, None) if tmp: tmp = tmp.split(',') for t in tmp...
packages.extend(modules)
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): modules = self.templates["control.modules"] modules = self.process_packages(modules, vars)
self.patch_deapply(patch, patchinf)
self.patch_deapply(patch, patchinfo)
def apply(self): if self.reverse: for operation, patch, patchinfo in self[::-1]: if operation == '.': print """\
'home': '/usr/src/kernel-patches/all/%s' % self.version['linux']['upstream'],
'home': '/usr/src/kernel-patches/all/%s/debian' % self.version['linux']['upstream'],
def do_extra(self, packages, makefile): apply = self.templates['patch.apply'] unpatch = self.templates['patch.unpatch']
file('debian/bin/patch-apply', 'w').write(apply) file('debian/bin/patch-unpatch', 'w').write(unpatch)
file('debian/bin/patch.apply', 'w').write(apply) file('debian/bin/patch.unpatch', 'w').write(unpatch)
def do_extra(self, packages, makefile): apply = self.templates['patch.apply'] unpatch = self.templates['patch.unpatch']
if subarch in config_entry.get('not-subarches', [subarch]):
if subarch in config_entry.get('not-subarches', []):
def do_module(self, module, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): config_entry = self.config['base', module] vars.update(config_entry) vars['module'] = module makeflags['MODULE'] = module
('modules', 'MODULES',),
def do_flavour_setup(self, vars, makeflags, arch, subarch, flavour): vars.update(self.config.get(('image', arch, subarch, flavour), {})) for i in ( ('compiler', 'COMPILER'), ('image-postproc', 'IMAGE_POSTPROC'), ('initramfs', 'INITRAMFS',), ('kernel-arch', 'KERNEL_ARCH'), ('kernel-header-dirs', 'KERNEL_HEADER_DIRS'), (...
image = self.templates["control.image"]
image_type_modulesextra = self.templates["control.image.type-modulesextra"] image_type_modulesinline = self.templates["control.image.type-modulesinline"] image_type_standalone = self.templates["control.image.type-standalone"]
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): image = self.templates["control.image"] headers = self.templates["control.headers"] modules = self.templates["control.modules"] image_latest = self.templates["control.image.latest"] headers_latest = self.templates["contro...
modules = self.templates["control.modules"]
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): image = self.templates["control.image"] headers = self.templates["control.headers"] modules = self.templates["control.modules"] image_latest = self.templates["control.image.latest"] headers_latest = self.templates["contro...
if vars['type'] == 'plain-xen': p = self.process_package(modules[0], vars) image_depends.extend(p['Reverse-Depends']) del p['Reverse-Depends'] packages_own.append(p)
if vars['type'] == 'plain-s390-tape': image = image_type_standalone elif vars['type'] == 'plain-xen': image = image_type_modulesextra else: image = image_type_modulesinline
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): image = self.templates["control.image"] headers = self.templates["control.headers"] modules = self.templates["control.modules"] image_latest = self.templates["control.image.latest"] headers_latest = self.templates["contro...
if vars.get('modules', True):
if image in (image_type_modulesextra, image_type_modulesinline): makeflags['MODULES'] = True
def do_flavour_packages(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): image = self.templates["control.image"] headers = self.templates["control.headers"] modules = self.templates["control.modules"] image_latest = self.templates["control.image.latest"] headers_latest = self.templates["contro...
self.abiname = self.vars['abiname'] = '-%s' % self.config['abiname',]['abiname']
self.abiname = self.vars['abiname'] = '-%s' % self.config['abi',]['abiname']
def process_changelog(self): version = self.changelog[0]['Version'] self.process_version(version) if version['modifier'] is not None: self.abiname = self.vars['abiname'] = '' else: self.abiname = self.vars['abiname'] = '-%s' % self.config['abiname',]['abiname']
makeflags['REVISIONS'] = ' '.join([i['Version']['debian'] for i in self.changelog[::-1]]),
makeflags['REVISIONS'] = ' '.join([i['Version']['debian'] for i in self.changelog[::-1]])
def do_arch_setup(self, vars, makeflags, arch): vars.update(self.config.get(('image', arch), {})) makeflags['REVISIONS'] = ' '.join([i['Version']['debian'] for i in self.changelog[::-1]]),
self._read_base()
def __init__(self, dirs = []): self._dirs = dirs self._read_base()
config_entry = self.config.merge('base', None, arch, subarch, flavour)
config_entry = self.config.merge('base', arch, subarch, flavour)
def do_flavour(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra): config_entry = self.config.merge('base', None, arch, subarch, flavour) if config_entry.get('modules', True) is False: return
class config_reader_modules(config.config_reader):
class config_reader_modules(config.config_reader_arch):
def process_changelog(self): changelog = read_changelog() self.version = changelog[0]['Version'] if self.version['linux']['modifier'] is not None: self.abiname = '' else: self.abiname = '-%s' % self.config['abi',]['abiname'] self.vars = self.process_version_linux(self.version, self.abiname)
def merge(self, section, module, *args): ret = {} ret.update(super(config_reader_modules, self).merge(section, *args)) if module: ret.update(super(config_reader_modules, self).merge(section, module, *args)) return ret
def merge(self, section, module, *args): ret = {} ret.update(super(config_reader_modules, self).merge(section, *args)) if module: ret.update(super(config_reader_modules, self).merge(section, module, *args)) return ret
self.orig = '%s-%s.orig' % (source, version)
self.orig = '%s-%s' % (source, version)
def __init__(self, input_tar, input_patch = None): self.log = sys.stdout.write
install_deb = []
def do_package(self, packages, makefile, package, vars, makeflags): config_entry = self.config['base', package] vars.update(config_entry) vars['package'] = package
hook_filename = "debian/firmware_%s" % package
hook_filename = "debian/firmware-%s.hook.initramfs-tools" % package
def do_package(self, packages, makefile, package, vars, makeflags): config_entry = self.config['base', package] vars.update(config_entry) vars['package'] = package
os.chmod(hook_filename, 0755) install_deb.append("%s /usr/share/initramfs-tools/hooks" % hook_filename)
def do_package(self, packages, makefile, package, vars, makeflags): config_entry = self.config['base', package] vars.update(config_entry) vars['package'] = package
file("debian/firmware-%s.install" % package, 'w').write('\n'.join(install + install_deb) + '\n')
file("debian/firmware-%s.dirs" % package, 'w').write("/usr/share/initramfs-tools/hooks\n") file("debian/firmware-%s.install" % package, 'w').write('\n'.join(install) + '\n')
def do_package(self, packages, makefile, package, vars, makeflags): config_entry = self.config['base', package] vars.update(config_entry) vars['package'] = package
super(_sorted_dict, self).__init__()
super(sorted_dict, self).__init__()
def __init__(self, entries = None): super(_sorted_dict, self).__init__() self._list = [] if entries is not None: for key, value in entries: self[key] = value
super(_sorted_dict, self).__delitem__(key)
super(sorted_dict, self).__delitem__(key)
def __delitem__(self, key): super(_sorted_dict, self).__delitem__(key) self._list.remove(key)