rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
app_label = "Company" | def __unicode__(self): return '[%s] %s' %(self.id, self.name) | |
app_label = 'auth' | def __unicode__(self): return '[%s] %s' %(self.id, self.name) | |
self.val['name'] = self.names[str(i+1)] | if str(i+1) in self.names.keys(): self.val['name'] = self.names[str(i+1)] else: self.val['name'] = 'int ' + str(i+1) | def extract(self): self.output = '' self.val['total'] = 0.0 for line in self.splitlines(): if line[0] == 'intr': self.intset2 = [ long(int) for int in line[3:] ] |
info(1, 'Module %s is still experimental.') % self.filename | info(1, 'Module %s is still experimental.' % self.filename) | def check(self): info(1, 'Module %s is still experimental.') % self.filename |
self.intset1 = [ 0 ] * 512 | self.intset1 = [ 0 ] * 1024 | def __init__(self): self.name = 'most frequent' self.vars = ('interrupt',) self.type = 's' self.width = 20 self.scale = 0 self.intset1 = [ 0 ] * 512 self.open('/proc/stat') self.names = self.names() |
self.vars = ('system', 'user', 'total') | self.vars = ('user', 'system', 'total') | def __init__(self): self.name = 'dstat cputime' self.vars = ('system', 'user', 'total') self.type = 'd' self.width = 4 self.scale = 100 |
self.set2['system'] = float(l[0]) self.set2['user'] = float(l[1]) | self.set2['user'] = float(l[0]) self.set2['system'] = float(l[1]) | def extract(self): ### Extract counters l = resource.getrusage(resource.RUSAGE_SELF) |
key = 'None' | key = '' | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = self.xmlrepr.createElement(node.__class__.__name__ + "Ast") node_xmlrepr.setAttribute('nodecnt', str(self.nodecnt)) self.currentnode.appendChild(node_xmlrepr) save_currentnod... |
multiple_keys.append('None') | multiple_keys.append('') | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = self.xmlrepr.createElement(node.__class__.__name__ + "Ast") node_xmlrepr.setAttribute('nodecnt', str(self.nodecnt)) self.currentnode.appendChild(node_xmlrepr) save_currentnod... |
direct_assignment_line = ''' v->%{TARGET} = node->v.%{VALUE};''' | direct_assignment_line = ''' v->%{TARGET} = node->v.%{KIND_W/O_SUFFIX}.%{VALUE};''' direct_assignment_line_any = ''' v->%{TARGET} = node->v.%{VALUE};''' | # sdef example line: |
for ( int _i = 0; _i < node->v.%{KIND_W/O_SUFFIX}.%{VALUE}.size; _i++ ) { v->%{TARGET}.append((ExpressionAst::%{AST_TYPE}) node->v.%{KIND_W/O_SUFFIX}.%{VALUE}.elements[_i]); | for ( int _i = 0; _i < node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->size; _i++ ) { v->%{TARGET}.append((ExpressionAst::%{AST_TYPE}) node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->elements[_i]); | # sdef example line: |
for ( int _i = 0; _i < node->v.%{KIND_W/O_SUFFIX}.%{VALUE}.size; _i++ ) { v->%{TARGET}.append(new Python::Identifier(PyString_AsString(PyObject_Str(node->v.%{KIND_W/O_SUFFIX}.%{VALUE}.elements[_i]))); | for ( int _i = 0; _i < node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->size; _i++ ) { Python::Identifier* id = new Python::Identifier(PyString_AsString(PyObject_Str( reinterpret_cast<PyObject*>(node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->elements[_i]) ))); v->%{TARGET}.append(id); | # sdef example line: |
if plugintypestr == 'Ast': return '_node' | if plugintypestr == 'Ast': return '_stmt' | def pluginAstToPythonAstType(plugintypestr): if plugintypestr == 'ExpressionAst': return '_expr' if plugintypestr == 'StatementAst' : return '_stmt' if plugintypestr == 'NameAst': return '_expr' if plugintypestr == 'ExceptionHandlerAst': return '_excepthandler' if plugintypestr == 'ComprehensionAst': return '_comprehen... |
raw = direct_assignment_line | raw = direct_assignment_line if not any else direct_assignment_line_any | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
if len(lines) > 1: | if not does_match_any[index]: | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
result->endCol = node->col_offset + 10; result->startLine = node->lineno; result->endLine = node->lineno; | result->endCol = node->col_offset; result->startLine = node->lineno - 1; result->endLine = node->lineno - 1; | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
else: appendix = '' | appendix += ''' // Walk through the tree and set proper end columns and lines, as the python parser sadly does not do this for us if ( result->hasUsefulRangeInformation ) { Ast* parent = result->parent; while ( parent ) { if ( parent->endLine < result->endLine ) { parent->endLine = result->endLine; parent->endCol = res... | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
sys.stdout.write(etree.tostring(v.basenode, xml_declaration=True, pretty_print=True)) | sys.stdout.write(etree.tostring(v.basenode, xml_declaration=True, pretty_print=True, encoding='UTF-8')) | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = etree.Element(node.__class__.__name__ + "Ast") node_xmlrepr.set('nodecnt', str(self.nodecnt)) self.currentnode.append(node_xmlrepr) save_currentnode = self.currentnode self.c... |
node_xmlrepr.set(field.lower(), str(value)) | try: node_xmlrepr.set(field.lower(), str(value)) except: sys.stderr.write("Warning: Invalid string literal replaced by empty string!\n") node_xmlrepr.set(field.lower(), "") | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = etree.Element(node.__class__.__name__ + "Ast") node_xmlrepr.set('nodecnt', str(self.nodecnt)) self.currentnode.append(node_xmlrepr) save_currentnode = self.currentnode self.c... |
v.visit(ast.parse(f)) | parsetree = ast.parse(f) | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = etree.Element(node.__class__.__name__ + "Ast") node_xmlrepr.set('nodecnt', str(self.nodecnt)) self.currentnode.append(node_xmlrepr) save_currentnode = self.currentnode self.c... |
sys.stderr.write(str(e) + ':::?:::?:::') | sys.stderr.write('?:::?:::'+str(e)+':::?') | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = etree.Element(node.__class__.__name__ + "Ast") node_xmlrepr.set('nodecnt', str(self.nodecnt)) self.currentnode.append(node_xmlrepr) save_currentnode = self.currentnode self.c... |
v.visit(ast.parse(f)) print v.xmlrepr.toprettyxml(indent = " ") | try: v.visit(ast.parse(f)) except Exception as e: sys.stderr.write(str(e.lineno) + ':' + str(e.offset)) else: sys.stdout.write(v.xmlrepr.toprettyxml(indent = " ")) | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = self.xmlrepr.createElement(node.__class__.__name__ + "Ast") node_xmlrepr.setAttribute('nodecnt', str(self.nodecnt)) self.currentnode.appendChild(node_xmlrepr) save_currentnod... |
some_instance.some_method() | some_instance.some_method().foobar some_instance.some_method(some_arg, some_arg2).second_attribute some_instance \ . attribute \ .funcfunc(argarg, arg2arg) \ .foo | def some_class(foo, bar): attr1 = 3 attr2 = 5 attr3 = 'str' |
return 0; // this will never be reached, but avoids gcc warnings | %{APPENDIX} return result; | # sdef example line: |
return 0; // this will never be reached, but avoids gcc warnings | return v; | # sdef example line: |
return v; | result = v; break; | # sdef example line: |
reinterpret_cast<PyObject*>(node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->elements[_i]) | static_cast<PyObject*>(node->v.%{KIND_W/O_SUFFIX}.%{VALUE}->elements[_i]) | # sdef example line: |
ast->body = visitNodeList<_expr, Ast>(syntaxtree->v.Module.body); | ast->body = visitNodeList<_stmt, Ast>(syntaxtree->v.Module.body); | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
T* currentNode = reinterpret_cast<T*>(node->elements[i]); | T* currentNode = static_cast<T*>(node->elements[i]); | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
func = func_structure.replace('%{RULE_FOR}', index).replace('%{SWITCH_LINES}', current_switch_lines) | func = func_structure.replace('%{RULE_FOR}', index).replace('%{SWITCH_LINES}', current_switch_lines).replace('%{APPENDIX}', appendix) | raise SyntaxError('Invalid syntax in sdef file, line: ' + rule) |
sys.stderr.write(str(e.lineno) + ':::' + str(e.offset)) sys.stderr.write(":::" + str(type(e)).replace('<type \'exceptions.', '').replace('\'>', '') + ':::' + str(e.msg) + ": \"" + str(e.text).replace("\n", "") + "\"") | try: sys.stderr.write(str(e.lineno) + ':::' + str(e.offset)) sys.stderr.write(":::" + str(type(e)).replace('<type \'exceptions.', '').replace('\'>', '') + ':::' + str(e.msg) + ": \"" + str(e.text).replace("\n", "") + "\"") except: sys.stderr.write(str(e) + ':::?:::?:::') | def generic_visit(self, node): self.nodecnt += 1 #self.childNodeMap[self.nodecnt] = node self.childNodeMap[node] = self.nodecnt node_xmlrepr = etree.Element(node.__class__.__name__ + "Ast") node_xmlrepr.set('nodecnt', str(self.nodecnt)) self.currentnode.append(node_xmlrepr) save_currentnode = self.currentnode self.c... |
def wrapper(*args, **args): | def wrapper(*args, **kargs): | def wrapper(*args, **args): thread = threading.Thread(target=func, args=args, kwargs=kwargs) thread.start() return thread |
self.assertEquals(pl[path][0], [u"two", u"test2"]) self.assertEquals(pl[path][1], [u"three", u"test3"]) self.assertEquals(pl[path][2], [u"one", u"test1"]) | self.assertTrue([u"two", u"test2"] in pl[path]) self.assertTrue([u"three", u"test3"] in pl[path]) self.assertTrue([u"one", u"test1"] in pl[path]) | def testDirectoryContainsThreeFileRecurse(self): path = os.path.join(u"tests", u"data", u"plugins", u"three") pl = self.gen_pre_pluginlist([path]) self.assertEquals(len(pl[path]), 3) self.assertEquals(pl[path][0], [u"two", u"test2"]) self.assertEquals(pl[path][1], [u"three", u"test3"]) self.assertEquals(pl[path][2], [u... |
"<Folder name='folder1' path='/somewhere'>\n<File name='00-Artist-Album.m3u' extension='.m3u' path='' />\n<File name='00-Artist-Album.nfo' extension='.nfo' path='' />\n<File name='01-title1.mp3' extension='.mp3' path='' />\n<File name='02-title2.mp3' extension='.mp3' path='' />\n<File name='03-title3.mp3' extension='.m... | "<Folder name='folder1' path='/somewhere'>\n%s\n</Folder>" % file_list_repr | def testFolderFunctionReprWithFiles(self): folder = create_folder1() self.assertEquals(repr(folder), "<Folder name='folder1' path='/somewhere'>\n<File name='00-Artist-Album.m3u' extension='.m3u' path='' />\n<File name='00-Artist-Album.nfo' extension='.nfo' path='' />\n<File name='01-title1.mp3' extension='.mp3' path=''... |
This look at the extension to determine a class to use (eg: AudioFile for mp3 file) and fill data""" | This function try to determine file type by using extension and instancy the good class. eg: use of AudioFile class for a mp3 file) fill data fullpath -- an unicode string representing to full path to access a file. Return a BaseFile instance object. """ | def factory(fullpath): """This is the factory function of the file class. This look at the extension to determine a class to use (eg: AudioFile for mp3 file) and fill data""" |
if splitext[1] is not u"": | if not len(splitext[1]) == 0: | def factory(fullpath): """This is the factory function of the file class. This look at the extension to determine a class to use (eg: AudioFile for mp3 file) and fill data""" |
self.dict = yaml.load( open(file_name, "r").read(), Loader=Loader | file = codecs.open( file_name, "r", sys.getfilesystemencoding() | def load(self, file_name): """ Load configuration from a yaml file |
file = open(file_name, "w+") | file = codecs.open( file_name, "w+", sys.getfilesystemencoding() ) | def save(self, file_name): """ Save configuration to a yaml file |
self.file = BaseFile.factory("tests/data/file/name.ext") | self.path = os.path.join("tests", "data", "file") self.file_name = "name.ext" self.file_path = os.path.join(self.path, self.file_name) self.file = BaseFile.factory(self.file_path) | def setUp(self): self.file = BaseFile.factory("tests/data/file/name.ext") |
self.assertEquals(self.file.name, "name.ext", "Factory must set the name to 'name' and it was '%s' !" % self.file.name) | self.assertEquals( self.file.name, self.file_name, "Factory must set the name to '%s' and it was '%s' !" % ( self.file_name, self.file.name ) ) | def testName(self): self.assertEquals(self.file.name, "name.ext", "Factory must set the name to 'name' and it was '%s' !" % self.file.name) |
self.assertEquals(self.file.path, "tests/data/file", "Factory must set path to 'tests/data/file/name.ext' ans it was '%s' !" % self.file.path ) | self.assertEquals( self.file.path, self.path, "Factory must set path to '%s' ans it was '%s' !" % ( self.path, self.file.path ) ) | def testPath(self): self.assertEquals(self.file.path, "tests/data/file", "Factory must set path to 'tests/data/file/name.ext' ans it was '%s' !" % self.file.path ) |
self.assertEquals(self.file.get_fullpath(), "tests/data/file/name.ext") | self.assertEquals(self.file.get_fullpath(), self.file_path) | def testFullpath(self): self.assertEquals(self.file.get_fullpath(), "tests/data/file/name.ext") |
class TestPluginManagerConstructor(TestPlugin): | class TestPluginManagerBase(TestPlugin): def gen_config(self, path_list=[], black_list=[], activate_list=[]): return { "path_list": path_list, "black_list": black_list, "activate_list": activate_list, } def gen_pluginmanager(self, path_list=[], black_list=[], activate_list=[]): return PluginManager( config=self.gen_co... | def testDefault(self): self.assertEquals(self.p.type, u"research") self.assertEquals(self.p.priority, 0) self.assertNone(self.p.investigate_class) |
self.assertIsInstance(pm, DictProxy) self.assertIsInstance(pm.config, dict) self.assertIsInstance(pm.dict, dict) | def testDefaultType(self): pm = PluginManager() self.assertIsInstance(pm, DictProxy) self.assertIsInstance(pm.config, dict) self.assertIsInstance(pm.dict, dict) | |
class TestPluginManagerValidateConfig(TestPlugin): | class TestPluginManagerValidateConfig(TestPluginManagerBase): | def testNotSingleton(self): pm1 = PluginManager() pm2 = PluginManager() self.assertNotEquals(pm1, pm2) |
class TestPluginManagerPrePluginList(TestPlugin): def gen_config(self, path_list=[], black_list=[], activate_list=[]): return { "path_list": path_list, "black_list": black_list, "activate_list": activate_list, } def gen_pluginmanager(self, path_list=[], black_list=[], activate_list=[]): return PluginManager( config=se... | class TestPluginManagerPrePluginList(TestPluginManagerBase): | def testGoodConfig(self): pm = PluginManager(config={"path_list": []}) (status, message) = pm.validate_config() self.assertTrue(status) self.assertEquals(message, u"") |
class TestPluginManagerLoad(TestPluginManagerPrePluginList): | class TestPluginManagerLoad(TestPluginManagerBase): def testOne(self): path = os.path.join(u"tests", u"data", u"plugins", u"one") pm = self.gen_pluginmanager([path]) pm.ensure_path_list_in_sys_path() pm.load("test1") self.assertTrue(pm.has_key("test1")) def testThree(self): path = os.path.join(u"tests", u"data", u"plu... | def testDirectoryContainsThreeFileRecurse(self): path = os.path.join(u"tests", u"data", u"plugins", u"three") pl = self.gen_pre_pluginlist([path]) self.assertEquals(len(pl[path]), 3) self.assertTrue(u"two.test2" in pl[path]) self.assertTrue(u"three.test3" in pl[path]) self.assertTrue(u"one.test1" in pl[path]) |
if (line.find("\\Demo_Colour\\..\\..") != -1): | if (trackPrint): trackPrint = True | def replaceAbsolutePaths(fileName): print "Converting " + fileName file = open(fileName,"r") relpath = os.path.relpath(dir_sources, currentFolder) relpath = relpath.replace('\\','/') #print "Current folder: " + currentFolder #print "Relative path: " + relpath #print "dir_sources: " + dir_sources #print os.path.join(c... |
os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) | os.system("cppcheck --enable=all -I Scripts/cppcheck " + folder) | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) |
os.system("cppcheck --enable=all -I Scripts/cppheck -I MyGUIEngine/include MyGUIEngine/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) | |
os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck -I Platforms/OpenGL/OpenGLPlatform/include Platforms/OpenGL/OpenGLPlatform/src") | os.system("cppcheck --enable=all -I Scripts/cppcheck -I Platforms/OpenGL/OpenGLPlatform/include Platforms/OpenGL/OpenGLPlatform/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) |
os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck -I Platforms/Ogre/OgrePlatform/include Platforms/Ogre/OgrePlatform/src") | os.system("cppcheck --enable=all -I Scripts/cppcheck -I Platforms/Ogre/OgrePlatform/include Platforms/Ogre/OgrePlatform/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) |
os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck -I Platforms/DirectX/DirectXPlatform/include Platforms/DirectX/DirectXPlatform/src") | os.system("cppcheck --enable=all -I Scripts/cppcheck -I Platforms/DirectX/DirectXPlatform/include Platforms/DirectX/DirectXPlatform/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) |
os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck -I MyGUIEngine/include MyGUIEngine/src") | os.system("cppcheck --enable=all -I Scripts/cppheck -I MyGUIEngine/include MyGUIEngine/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I MyGUIEngine/Scripts/cppheck " + folder) |
os.system("vera++ ../../MyGUIEngine/src/*.cpp -profile default 2> temp.vera++") parseOutput() os.system("vera++ ../../MyGUIEngine/include/*.h -profile default 2> temp.vera++") parseOutput() | checkDir("MyGUIEngine/src/*.cpp") checkDir("MyGUIEngine/include/*.h") checkDir("*/*/*.h") checkDir("*/*/*.cpp") checkDir("Common/*/*/*.h") checkDir("Common/*/*/*.cpp") checkDir("Platforms/*/*/*/*.h") checkDir("Platforms/*/*/*/*.cpp") | def parseOutput(): file = open("temp.vera++", 'r') line = file.readline() while line != "": line = line[0:len(line)-1] if (not isIgnoredWarning(line)): print line line = file.readline() file.close () |
os.system("cppcheck --enable=all -I Scripts/cppcheck -I Platforms/OpenGL/OpenGLPlatform/include Platforms/OpenGL/OpenGLPlatform/src") | def checkFolderSources(folder) : os.system("cppcheck --enable=all -I Scripts/cppcheck " + folder) | |
except: | except Exception : | def get_image_info(filename, options) : """returns the image's format""" try : image = Image.open(filename) bad_image = image.verify() image_format = image.format sequenced = is_image_sequenced(image) if image_format in options.formats : print(filename, image.format, image.mode+' ') except: bad_image = 1 image_format =... |
print('\tImage could not be optimized, so I am restoring it from backup...',) | print('\tImage could not be optimized, so I am restoring it from '\ ' backup...') | def recover_file(backup_filename, new_filename, options) : """recover the original version of a file that did not optimize well""" try : if options.verbose : print('\tImage could not be optimized, so I am restoring it from backup...',) unbackedup_filename = replace_ext(backup_filename, '') os.remove(new_filename) os.r... |
except (Exception, why): | except Exception as why: | def recover_file(backup_filename, new_filename, options) : """recover the original version of a file that did not optimize well""" try : if options.verbose : print('\tImage could not be optimized, so I am restoring it from backup...',) unbackedup_filename = replace_ext(backup_filename, '') os.remove(new_filename) os.r... |
return self.document.from_xml(value) | return self.document_type.from_xml(value) | def to_python(self, value): if isinstance(value, ElementTree._ElementInterface): return self.document.from_xml(value) return super(EmbeddedDocumentField, self).to_python(value) |
def transform_coordinates(self, coords): if getattr(self, 'ItemTransform', False): | def get_spread_transform(self): """ Returns the transform matrix for this element relative to the spread """ if hasattr(self, 'ItemTransform'): | def transform_coordinates(self, coords): if getattr(self, 'ItemTransform', False): transformation = numpy.matrix([ [self.ItemTransform[0], self.ItemTransform[1], 0], [self.ItemTransform[2], self.ItemTransform[3], 0], [self.ItemTransform[4], self.ItemTransform[5], 1], ]) result = numpy.matrix([coords[0], coords[1], 1]) ... |
result = numpy.matrix([coords[0], coords[1], 1]) * transformation return (result[0, 0], result[0, 1]) | else: transformation = numpy.identity(3) | def transform_coordinates(self, coords): if getattr(self, 'ItemTransform', False): transformation = numpy.matrix([ [self.ItemTransform[0], self.ItemTransform[1], 0], [self.ItemTransform[2], self.ItemTransform[3], 0], [self.ItemTransform[4], self.ItemTransform[5], 1], ]) result = numpy.matrix([coords[0], coords[1], 1]) ... |
return self._parent.transform_coordinates(coordinates) | return transformation * self._parent.get_spread_transform() | def transform_coordinates(self, coords): if getattr(self, 'ItemTransform', False): transformation = numpy.matrix([ [self.ItemTransform[0], self.ItemTransform[1], 0], [self.ItemTransform[2], self.ItemTransform[3], 0], [self.ItemTransform[4], self.ItemTransform[5], 1], ]) result = numpy.matrix([coords[0], coords[1], 1]) ... |
return coordinates | return transformation def transform_coordinates(self, coords): """ Returns coordinates relative to the spread given coordinates relative to this element. """ coords_matrix = numpy.matrix([coords[0], coords[1], 1]) result = coords_matrix * self.get_spread_transform() return (result[0, 0], result[0, 1]) | def transform_coordinates(self, coords): if getattr(self, 'ItemTransform', False): transformation = numpy.matrix([ [self.ItemTransform[0], self.ItemTransform[1], 0], [self.ItemTransform[2], self.ItemTransform[3], 0], [self.ItemTransform[4], self.ItemTransform[5], 1], ]) result = numpy.matrix([coords[0], coords[1], 1]) ... |
f.write(line + "\n") | f.write(line + os.linesep) | def update(lang): print "\nUpdate " + lang # buffer translation file (always open binary, handle newline uniformly) f = open(lang, "rbU") translation = [] for line in f: translation.append(line.rstrip("\n")) f.close outList = [] # find new fields for line in english: # header if re.search("\[Text\]", line, re.I): out... |
results[column][np.equal(results[column], None)] = null | results[column][np.equal(np.array(results[column], dtype=np.object), None)] = null | def read(self, dbtype, *args, **kwargs): ''' Required Arguments: *dbtype*: [ 'sqlite' | 'mysql' | 'postgres' ] The SQL database type Optional arguments (only for Table.read() class): *table*: [ string ] The name of the table to read from the database (this is only required if there are more than one table in the dat... |
format, bzero = hdu.columns[i].format[-1], hdu.columns[i].bzero | format, bzero = hdu.columns[i].format, hdu.columns[i].bzero format = format.strip("1234567890.") if type.type is np.string_ and format in ['I','F','E','D']: if format == 'I': type = np.int64 elif format in ['F','E']: type = np.float32 elif format == 'D': type = np.float64 | def read(self, filename, hdu=None, verbose=True): ''' Read a table from a FITS file Required Arguments: *filename*: [ string ] The FITS file to read the table from Optional Keyword Arguments: *hdu*: [ integer ] The HDU to read from the FITS file (this is only required if there are more than one table in the FITS fi... |
table = np.array(f[table]) | self._setup_table(len(f[table]), f[table].dtype) | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
for name in table.dtype.names: self.add_column(name, table[name]) | for name in f[table].dtype.names: self.data[name][:] = f[table][name][:] | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
position = self.names.index(before) | position = list(self.names).index(before) | def add_column(self, name, data, unit='', null='', description='', \ format=None, dtype=None, before=None, after=None, position=None, mask=None, fill=None): ''' Add a column to the table |
position = self.names.index(after) + 1 | position = list(self.names).index(after) + 1 | def add_column(self, name, data, unit='', null='', description='', \ format=None, dtype=None, before=None, after=None, position=None, mask=None, fill=None): ''' Add a column to the table |
pos = self.names.index(old_name) | pos = list(self.names).index(old_name) | def rename_column(self, old_name, new_name): ''' Rename a column from the table |
print attribute, value | def __setattr__(self, attribute, value): print attribute, value if attribute in ['unit', 'description', 'format']: self.__dict__[attribute] = value elif attribute in ['null', 'dtype']: raise Exception("Cannot change %s through the columns object" % attribute) else: raise AttributeError(attribute) | |
overwrite=False): | overwrite=False, ignore_groups=False): | def write(self, filename, compression=False, group="", append=False, overwrite=False): ''' Write the table to an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to write the table to OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to ... |
if '/' in name: warnings.warn("'/' character removed from table name") name = name.replace('/', '-') | def write(self, filename, compression=False, group="", append=False, overwrite=False): ''' Write the table to an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to write the table to OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to ... | |
self.read(*args, type='fits', **kwargs) | kwargs['type'] = 'fits' self.read(*args, **kwargs) | def fits_read(self, *args, **kwargs): warnings.warn("WARNING: fits_read is deprecated; use read instead") self.read(*args, type='fits', **kwargs) |
self.read(*args, type='vo', **kwargs) | kwargs['type'] = 'vo' self.read(*args, **kwargs) | def vo_read(self, *args, **kwargs): warnings.warn("WARNING: vo_read is deprecated; use read instead") self.read(*args, type='vo', **kwargs) |
self.read(*args, type='sql', **kwargs) | kwargs['type'] = 'sql' self.read(*args, **kwargs) | def sql_read(self, *args, **kwargs): warnings.warn("WARNING: sql_read is deprecated; use read instead") self.read(*args, type='sql', **kwargs) |
self.read(*args, type='ipac', **kwargs) | kwargs['type'] = 'ipac' self.read(*args, **kwargs) | def ipac_read(self, *args, **kwargs): warnings.warn("WARNING: ipac_read is deprecated; use read instead") self.read(*args, type='ipac', **kwargs) |
self.write(*args, type='fits', **kwargs) | kwargs['type'] = 'fits' self.write(*args, **kwargs) | def fits_write(self, *args, **kwargs): warnings.warn("WARNING: fits_write is deprecated; use write instead") self.write(*args, type='fits', **kwargs) |
self.write(*args, type='vo', **kwargs) | kwargs['type'] = 'vo' self.write(*args, **kwargs) | def vo_write(self, *args, **kwargs): warnings.warn("WARNING: vo_write is deprecated; use write instead") self.write(*args, type='vo', **kwargs) |
self.write(*args, type='sql', **kwargs) | kwargs['type'] = 'sql' self.write(*args, **kwargs) | def sql_write(self, *args, **kwargs): warnings.warn("WARNING: sql_write is deprecated; use write instead") self.write(*args, type='sql', **kwargs) |
self.write(*args, type='ipac', **kwargs) | kwargs['type'] = 'ipac' self.write(*args, **kwargs) | def ipac_write(self, *args, **kwargs): warnings.warn("WARNING: ipac_write is deprecated; use write instead") self.write(*args, type='ipac', **kwargs) |
f = filename | f, g = None, filename | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
tables = _list_tables(f) | tables = _list_tables(g) | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
self._setup_table(len(f[table]), f[table].dtype) | self._setup_table(len(g[table]), g[table].dtype) | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
for name in f[table].dtype.names: self.data[name][:] = f[table][name][:] | for name in g[table].dtype.names: self.data[name][:] = g[table][name][:] if f is not None: f.close() | def read(self, filename, table=None, verbose=True): ''' Read a table from an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to read the table from OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handle or group handle to read the table from Optional Keywo... |
if f: | if f is not None: | def write(self, filename, compression=False, group="", append=False, overwrite=False, ignore_groups=False): ''' Write the table to an HDF5 file Required Arguments: *filename*: [ string ] The HDF5 file to write the table to OR *file or group handle*: [ h5py.highlevel.File | h5py.highlevel.Group ] The HDF5 file handl... |
*pendantic*: [ True | False ] | *pedantic*: [ True | False ] | def vo_read(self, filename, pedantic=False, tid=-1, verbose=True): ''' Read a table from a VOT file |
*pendantic*: [ True | False ] | *pedantic*: [ True | False ] | def vo_read(self, filename, pedantic=False, verbose=True): ''' Read all tables from a VOT file |
with warnings.catch_warnings(): | original_filters = warnings.filters[:] if verbose: warnings.simplefilter("always") else: warnings.simplefilter("ignore") try: | def read(self, *args, **kwargs): ''' Read in a table or table set from a file/database. |
with warnings.catch_warnings(): | original_filters = warnings.filters[:] | def write(self, *args, **kwargs): ''' Write out a table or table set to a file/database. |
if verbose: warnings.simplefilter("always") else: warnings.simplefilter("ignore") | if verbose: warnings.simplefilter("always") else: warnings.simplefilter("ignore") try: | def write(self, *args, **kwargs): ''' Write out a table or table set to a file/database. |
if np.any(np.self.data[key] == self.columns[key].null): | if np.any(self.data[key] == self.columns[key].null): | def set_primary_key(self, key): ''' Set the name of the table column that should be used as a unique identifier for the record. This is the same as primary keys in SQL databases. A primary column cannot contain NULLs and must contain only unique quantities. |
query += ", PRIMARY KEY (%s)" % primary_key | query += ", PRIMARY KEY (%s%s%s)" % \ (quote[dbtype],primary_key,quote[dbtype]) | def create_table(cursor, dbtype, table_name, columns, primary_key=None): ''' Create a table in an SQL database Required Arguments: *cursor*: [ DB API cursor object ] A cursor for the current database in the DB API formalism *dbtype*: [ 'sqlite' | 'mysql' | 'postgres' ] The type of database *table_name*: [ string ] ... |
format = None | format = default_format[dtype[i].type] | def _setup_table(self, n_rows, dtype, units=None, descriptions=None, formats=None, nulls=None): |
'PCOUNT', 'GCOUNT', 'BITPIX'] | 'PCOUNT', 'GCOUNT', 'BITPIX', 'EXTNAME'] | def _check_pyfits_installed(): if not pyfits_installed: raise Exception("Cannot read/write FITS files - pyfits " + \ pyfits_minimum_version.vstring + " or later required") |
if hdu.header['XTENSION'] == 'BINTABLE' or \ hdu.header['XTENSION'] == 'ASCIITABLE': | if hdu.header['XTENSION'] in ['BINTABLE', 'ASCIITABLE', 'TABLE']: | def _list_tables(filename): hdulist = pyfits.open(filename) tables = {} for i, hdu in enumerate(hdulist[1:]): if hdu.header['XTENSION'] == 'BINTABLE' or \ hdu.header['XTENSION'] == 'ASCIITABLE': tables[i + 1] = hdu.name return tables |
self.add_column(field.name, table.array[field.name], \ unit=field.unit, mask=table.mask[field.name]) else: self.add_column(field.name, table.array[field.name], \ | self.add_column(colname, table.array[colname], \ unit=field.unit, mask=table.mask[colname]) else: self.add_column(colname, table.array[colname], \ | def vo_read(self, filename, pedantic=False, tid=-1, verbose=True): ''' Read a table from a VOT file |
new_table.table_name = copy(self.table_name) new_table.columns = copy(self.columns) new_table.keywords = copy(self.keywords) new_table.comments = copy(self.comments) | new_table.table_name = deepcopy(self.table_name) new_table.columns = deepcopy(self.columns) new_table.keywords = deepcopy(self.keywords) new_table.comments = deepcopy(self.comments) | def where(self, mask): ''' Select matching rows from the table and return a new table instance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.