bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _parse_results(self): self._resultset_cache = []
def _parse_results(self): self._resultset_cache = []
455,100
def resolve(self, value): bits = self.path.split(".")
def resolve(self, value): bits = self.path.split(".")
455,101
def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError assert ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported."
def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError if not ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported."
455,102
def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError assert ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported."
def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError assert ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported."
455,103
def read_pb_partitions(sampled_partitions_file, from_row=0, to_row=None, read_rates=True): site_indices_regex = r'^\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+' site_indices_pattern = re.compile(site_indices_regex) posterior = PosteriorOfPartitions() line_iter = iter(sampled_partitions_file) indices_tally = 0 samp...
def read_pb_partitions(sampled_partitions_file, from_row=0, to_row=None, read_rates=True): site_indices_regex = r'^\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+' site_indices_pattern = re.compile(site_indices_regex) posterior = PosteriorOfPartitions() line_iter = iter(sampled_partitions_file) indices_tally = 0 samp...
455,104
def teardown_class(cls): if hasattr(self, 'pack'): del self.pack if hasattr(self, 'part'): del self.part cls.remove_testfile()
def teardown_class(cls): cls.remove_testfile()
455,105
def part_edit_cmd(): 'Edit a part from an OOXML Package without unzipping it' parser = argparse.ArgumentParser(description=inspect.getdoc(part_edit_cmd)) parser.add_argument('path', help='Path to part (including path to zip file, i.e. ./file.zipx/part)') args = parser.parse_args() part_edit(args.path)
def part_edit_cmd(): 'Edit a part from an OOXML Package without unzipping it' parser = argparse.ArgumentParser(description=inspect.getdoc(part_edit_cmd)) parser.add_argument('path', help='Path to part (including path to zip file, i.e. ./file.zipx/part)') args = parser.parse_args() part_edit(args.path, args.reformat_xml...
455,106
def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
def part_edit(path, reformat_xml): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
455,107
def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] data = part.dump() if reformat_xml: data = etree.tostring(etree.fromstring(data), pretty_print=True) ef = EditableFile(data) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
455,108
def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save()
455,109
def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(item.name) base = base[1:] relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(...
def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(to_zip_name(item.name)) relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(ite...
455,110
def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(item.name) base = base[1:] relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(...
def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(item.name) base = base[1:] relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(...
455,111
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
def save(self, target=None): now = time.localtime(time.time()) ZipInfoNow = functools.partial(ZipInfo, date_time = now) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = ...
455,112
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfoNow('[Content_Types].xml') ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATED zf.wri...
455,113
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
455,114
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE...
455,115
def __init__(self): self.parts = {} self.base = '/' self.relationships = rels = Relationships(self, self) self[rels.name] = rels self.content_types = ContentTypes() self.content_types.add(ContentType.Default(rels.content_type, 'rels')) self.core_properties = None
def __init__(self): self.parts = {} self.base = '/' self.relationships = rels = Relationships(self, self) self[rels.name] = rels self.content_types = ContentTypes() self.content_types.add(ContentType.Default(rels.content_type, 'rels'))
455,116
def _validate_default(self, ct): assert ct.extension not in self.defaults return ct
def _validate_default(self, ct): if ct.extension in self.defaults: assert self.defaults[ct.extension] == ct return ct
455,117
def _validate_override(self, ct): assert ct.part_name not in self.overrides return ct
def _validate_override(self, ct): assert ct.part_name not in self.overrides return ct
455,118
def set_attr_if_tag(tag, attr=None, transform=identity): if attr is None: ns, attr = parse_tag(tag) elem = xml.find(tag) if elem and elem.text: value = transform(elem.text) setattr(self, attr, value)
def set_attr_if_tag(tag, attr=None, transform=identity): if attr is None: ns, attr = parse_tag(tag) elem = xml.find(tag) if elem is not None and elem.text: value = transform(elem.text) setattr(self, attr, value)
455,119
def define_refinement_paths(KSPRTOL, SSARTOL): # Define all the supported refinement paths: tests = {} # A A = PISMVerificationTest() A.name = "A" A.test = "isothermal SIA with a marine margin" A.path = "(refine dx=53.33,40,26.67,20,13.33,km, dx=dy and Mx=My=31,41,61,81,121)" A.Mx = [31, 41, 61, 81, 121] A.My = A.M...
def define_refinement_paths(KSPRTOL, SSARTOL): # Define all the supported refinement paths: tests = {} # A A = PISMVerificationTest() A.name = "A" A.test = "isothermal SIA with a marine margin" A.path = "(refine dx=53.33,40,26.67,20,13.33,km, dx=dy and Mx=My=31,41,61,81,121)" A.Mx = [31, 41, 61, 81, 121] A.My = A.M...
455,120
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[::stride],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzer...
455,121
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[::stride] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzer...
455,122
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dXp/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mas...
455,123
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][::stride,:,:]) # (t,y,x) k = np.no...
455,124
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
455,125
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
455,126
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
defgetRateOfChange(t,X,p,varname):#differenetiatetimealongtimeaxisdt=np.diff(t[:],axis=0)Xdim=X.ndimXunits=X.unitsifXdim==1:X=X[:]dXp=np.diff(X)dXpdt=dX/dtelifXdim==3:if'mask'innc.variables.keys():mask=np.array(nc.variables['mask'][:])#(t,y,x)k=np.nonzero((mask==1)^(mask==2)^(mask==3))mask2=np.ones_like(mask)mask2[k]=0...
455,127
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask...
455,128
def usagefailure(message): print message print print usage exit(2)
def usagefailure(message): print message print print usage exit(2)
455,129
def usagefailure(message): print message print print usage exit(2)
def usagefailure(message): print message print print usage exit(2)
455,130
def success(): print "Files are the same within given tolerance." exit(0)
def success(): print "Files are the same within tolerance %.1e" % tol exit(0)
455,131
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
455,132
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable.usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta = abs...
455,133
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable.usagefailure("ERROR: VARIABLE '%s' OF INCOMPATIBLE SHAPES (?) IN FILES" % name) ...
455,134
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari...
455,135
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened.usagefailure("ERROR: FILE '%s' CANNOT BE OP...
455,136
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
defcompare(file1,file2,variables,exclude,tol):try:fromnetCDF4importDatasetasNCexcept:fromnetCDF3importDatasetasNCfromnumpyimportunique,r_try:nc1=NC(file1,'r')nc2=NC(file2,'r')except:#Thiscanhappenifoneofthefilescouldnotbeopened.failure()if(exclude==False):iflen(variables)==0:vars1=nc1.variables.keys()vars2=nc2.variable...
455,137
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
455,138
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. usagefailure('ERROR: WRONG NUMBER OF ARGUM...
455,139
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NCfrom numpy import unique, r_try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure()if (exclude == False): if len(variabl...
455,140
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
455,141
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
455,142
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ...
455,143
def failure(): print "Files are different." exit(1)
def failure(): print "Files are different." exit(1)
455,144
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta = abs(var1...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta...
455,145
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta = abs(var1...
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: mask = isnan(var...
455,146
def compare_vars(nc1, nc2, name, tol, relative=False): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % n...
def compare_vars(nc1, nc2, name, tol, relative=False): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % n...
455,147
def maskout(nc, thk, name, thktol=1.0): from numpy import squeeze, isnan, ma try: var = squeeze(nc.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE" % name) var[thk<thktol] = -9999.0 return var
def maskout(nc, thk, name, thktol=1.0): from numpy import squeeze, isnan, ma try: var = squeeze(nc.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE" % name) if 't' in dims: for j in range(var.shape[0]): tmp = var[j] tmp[thk<thktol] = fill_value var[j] = tmp else: var[thk<thktol] = fill...
455,148
def success(): print "Files are the same within tolerance %.1e" % tol exit(0)
def success(relative): if relative: print "Files are the same within relative tolerance %.1e" % tol else: print "Files are the same within tolerance %.1e" % tol exit(0)
455,149
def compare_vars(nc1, nc2, name, tol): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: mask ...
def compare_vars(nc1, nc2, name, tol, relative=False): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % n...
455,150
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol, relative): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefai...
455,151
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
455,152
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
455,153
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
455,154
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
455,155
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO...
455,156
def get_projection_from_file(nc): ## First, check if we have a global attribute 'projection' ## which contains a Proj4 string: try: p = Proj(nc.projection) print('Found projection information in global attribute, using it') except: try: ## go through variables and look for 'grid_mapping' attribute for var in nc.variab...
def get_projection_from_file(nc): ## First, check if we have a global attribute 'projection' ## which contains a Proj4 string: try: p = Proj(nc.projection) print('Found projection information in global attribute, using it') except: try: ## go through variables and look for 'grid_mapping' attribute for var in nc.variab...
455,157
def get_projection_from_file(nc): ## First, check if we have a global attribute 'projection' ## which contains a Proj4 string: try: p = Proj(nc.projection) print('Found projection information in global attribute, using it') except: try: ## go through variables and look for 'grid_mapping' attribute for var in nc.variab...
def get_projection_from_file(nc): ## First, check if we have a global attribute 'projection' ## which contains a Proj4 string: try: p = Proj(nc.projection) print('Found projection information in global attribute, using it') except: try: ## go through variables and look for 'grid_mapping' attribute for var in nc.variab...
455,158
def SMsurface(h,x): b_x = SMcold_bedslope(x) s = a * abs(x) # ??? return b_x - (C / rho_g) * s**m / h**(m+1)
def SMsurface(h,x): b_x = SMcold_bedslope(x) s = a * abs(x) # ??? return b_x - (C / rho_g) * s**m / h**(m+1)
455,159
def make_collection_id(data): sio = StringIO.StringIO() for key in ( _version.version, 'base_url', 'script_extension', 'template_blacklist', 'template_exclusion_category', 'print_template_prefix', 'print_template_pattern', 'login_credentials', ): sio.write(repr(data.get(key))) mb = data.get('metabook') if mb: mbobj = j...
def make_collection_id(data): sio = StringIO.StringIO() for key in ( _version.version, 'base_url', 'script_extension', 'template_blacklist', 'template_exclusion_category', 'print_template_prefix', 'print_template_pattern', 'login_credentials', ): sio.write(repr(data.get(key))) mb = data.get('metabook') if mb: if isinst...
455,160
def normalize_and_get_image_path(self, name): assert isinstance(name, basestring) name = unicode(name) ns, partial, fqname = self.nshandler.splitname(name, defaultns=6) if ns != 6: return
defext = ext.replace(' ', '') normalize_and_get_image_path(self,ext = ext.replace(' ', '') name):ext = ext.replace(' ', '') assertext = ext.replace(' ', '') isinstance(name,ext = ext.replace(' ', '') basestring)ext = ext.replace(' ', '') nameext = ext.replace(' ', '') =ext = ext.replace(' ', '') unicode(name)ext = ext....
455,161
def normalize_and_get_image_path(self, name): assert isinstance(name, basestring) name = unicode(name) ns, partial, fqname = self.nshandler.splitname(name, defaultns=6) if ns != 6: return
defnormalize_and_get_image_path(self,name):assertisinstance(name,basestring)name=unicode(name)ns,partial,fqname=self.nshandler.splitname(name,defaultns=6)ifns!=6:return
455,162
def fix_wikipedia_siteinfo(siteinfo): # --- http://code.pediapress.com/wiki/ticket/754 if u'\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd' in [x.get("prefix", u"")[2:] for x in sitein...
def fix_wikipedia_siteinfo(siteinfo): # --- http://code.pediapress.com/wiki/ticket/754 if u'\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd' in [x.get("prefix", u"")[2:] for x in sitein...
455,163
def NS(self, args): """Returns the name of a given namespace number.""" namespaces = self.source.namespaces or {} ns = args[0] try: retval = namespaces[ns]['*'] except KeyError: retval = ''
def NS(self, args): """Returns the name of a given namespace number.""" try: namespaces = self.siteinfo["namespaces"] except (AttributeError, KeyError): from mwlib import siteinfo namespaces = siteinfo.get_siteinfo("en")["namespaces"] ns = args[0] try: retval = namespaces[ns]['*'] except KeyError: retval = ''
455,164
def getImageSize(self, img_node, img_path=None, max_print_width=None, max_print_height=None, fullsize_thumbs=False, img_size=None): max_w = getattr(img_node, 'width', None) max_h = getattr(img_node, 'height', None) if img_path: img = Image.open(img_path) px_w, px_h = img.size else: px_w, px_h = img_size ar = px_w/px_...
def getImageSize(self, img_node, img_path=None, max_print_width=None, max_print_height=None, fullsize_thumbs=False, img_size=None): max_w = getattr(img_node, 'width', None) max_h = getattr(img_node, 'height', None) if img_path: img = Image.open(img_path) px_w, px_h = img.size else: px_w, px_h = img_size ar = px_w/px_...
455,165
def __init__(self, cache_dir="cache", default_writer='rl', report_from_mail=None, report_recipients=None): self.cache_dir = utils.ensure_dir(cache_dir) self.mwrender_cmd = "mw-render" self.mwrender_logfile = "render-logfile" self.mwzip_cmd = "mw-zip" self.mwzip_logfile = "zip-logfile" self.mwpost_cmd = "mw-post" self....
def __init__(self, cache_dir="cache", default_writer='rl', report_from_mail=None, report_recipients=None): self.cache_dir = cache_dir self.mwrender_cmd = "mw-render" self.mwrender_logfile = "render-logfile" self.mwzip_cmd = "mw-zip" self.mwzip_logfile = "zip-logfile" self.mwpost_cmd = "mw-post" self.mwpost_logfile = ...
455,166
def __init__(self, cache_dir="cache", default_writer='rl', report_from_mail=None, report_recipients=None): self.cache_dir = utils.ensure_dir(cache_dir) self.mwrender_cmd = "mw-render" self.mwrender_logfile = "render-logfile" self.mwzip_cmd = "mw-zip" self.mwzip_logfile = "zip-logfile" self.mwpost_cmd = "mw-post" self....
def __init__(self, cache_dir="cache", default_writer='rl', report_from_mail=None, report_recipients=None): self.cache_dir = utils.ensure_dir(cache_dir) self.mwrender_cmd = "mw-render" self.mwrender_logfile = "render-logfile" self.mwzip_cmd = "mw-zip" self.mwzip_logfile = "zip-logfile" self.mwpost_cmd = "mw-post" self....
455,167
def main(): from gevent.wsgi import WSGIServer application = Application() address = "0.0.0.0", 8899 server = WSGIServer(address, application) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "bye."
def main(): from gevent.wsgi import WSGIServer cachedir = "cache" cachedir = utils.ensure_dir(cachedir) for i in range(0x100, 0x200): p = os.path.join(cachedir, hex(i)[3:]) if not os.path.isdir(p): os.mkdir(p) def app(*args, **kwargs): return Application(cachedir)(*args, **kwargs) address = "0.0.0.0", 8899 server = ...
455,168
def main(): from gevent.wsgi import WSGIServer application = Application() address = "0.0.0.0", 8899 server = WSGIServer(address, application) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "bye."
def main(): from gevent.wsgi import WSGIServer application = Application() address = "0.0.0.0", 8899 server = WSGIServer(address, app) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "bye."
455,169
def extract_member(zipfile, member, dstdir): """Copied and adjusted from Python 2.6 stdlib zipfile.py module. Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ assert dstdir.endswith(os.path.sep), "/ missing at end" targetpath = os.path.normpath(os.path.join(dstdir, member.filename))...
def extract_member(zipfile, member, dstdir): """Copied and adjusted from Python 2.6 stdlib zipfile.py module. Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ assert dstdir.endswith(os.path.sep), "/ missing at end" fn = member.filename if isinstance(fn, str): fn = unicode(fn, 'utf-8...
455,170
def got_result(data): try: error = data.get("error") except: print "ERROR:", data, kwargs raise if error: raise RuntimeError("%s: [fetching %s]" % (error.get("info", ""), self._build_url(**kwargs))) merge_data(retval, data["query"]) qc = data.get("query-continue", {}).values() if qc and query_continue: kw = kwargs...
def got_result(data): try: error = data.get("error") except: print "ERROR:", data, kwargs raise if error: raise RuntimeError("%r: [fetching %r]" % (error.get("info", ""), self._build_url(**kwargs))) merge_data(retval, data["query"]) qc = data.get("query-continue", {}).values() if qc and query_continue: kw = kwargs...
455,171
def __init__(self, pagename='', server="http://en.wikipedia.org", revisionid=0): self.pagename = pagename self.qpagename = pagename.replace(' ', '_') self.server = server self.revisionid = revisionid self.niceurl = urlparse.urljoin(self.server, 'wiki')
def __init__(self, pagename='', server="http://en.wikipedia.org", revisionid=0): self.pagename = pagename self.server = server self.revisionid = revisionid self.niceurl = urlparse.urljoin(self.server, 'wiki')
455,172
def __init__(self, pagename='', server="http://en.wikipedia.org", revisionid=0): self.pagename = pagename self.qpagename = pagename.replace(' ', '_') self.server = server self.revisionid = revisionid self.niceurl = urlparse.urljoin(self.server, 'wiki')
def __init__(self, pagename='', server="http://en.wikipedia.org", revisionid=0): self.pagename = pagename self.qpagename = pagename.replace(' ', '_') self.server = server self.revisionid = revisionid self.niceurl = urlparse.urljoin(self.server, 'wiki')
455,173
def PAGENAME(self, args): """Returns the name of the current page, including all levels (Title/Subtitle/Sub-subtitle)""" return self.pagename
def PAGENAME(self, args): """Returns the name of the current page, including all levels (Title/Subtitle/Sub-subtitle)""" return self.pagename
455,174
def SUBPAGENAME(self, args): """[MW1.6+] Returns the name of the current page, excluding parent pages ('Title/Subtitle' becomes 'Subtitle'). """ return self.pagename.split('/')[-1]
def SUBPAGENAME(self, args): """[MW1.6+] Returns the name of the current page, excluding parent pages ('Title/Subtitle' becomes 'Subtitle'). """ return self.pagename.split('/')[-1]
455,175
def BASEPAGENAME(self, args): """[MW1.7+] The basename of a subpage ('Title/Subtitle' becomes 'Title') """ return self.pagename.rsplit('/', 1)[0]
def BASEPAGENAME(self, args): """[MW1.7+] The basename of a subpage ('Title/Subtitle' becomes 'Title') """ return self.pagename.rsplit('/', 1)[0]
455,176
def NAMESPACE(self, args): """Returns the name of the namespace the current page resides in.""" ns, partial, full = self.nshandler.splitname(self.pagename) return full[:-len(partial)-1]
def NAMESPACE(self, args): """Returns the name of the namespace the current page resides in.""" ns, partial, full = self.nshandler.splitname(pagename) return full[:-len(partial)-1]
455,177
def NAMESPACEE(self, args): """Returns the name of the namespace the current page resides in. (quoted)""" return urlquote(self.NAMESPACE(args))
def NAMESPACEE(self, args): """Returns the name of the namespace the current page resides in. (quoted)""" return urlquote(self.NAMESPACE(args))
455,178
def __init__(self, siteinfo): assert siteinfo is not None
def __init__(self, siteinfo): assert siteinfo is not None
455,179
def removeBrokenChildren(self, node): """Remove Nodes (while keeping their children) which can't be nested with their parents.""" if node.__class__ in self.removeNodes.keys(): if _any([parent.__class__ in self.removeNodes[node.__class__] for parent in node.parents]): if node.children and not _any([ parent.__class__ in ...
def removeBrokenChildren(self, node): """Remove Nodes (while keeping their children) which can't be nested with their parents.""" if node.__class__ in self.removeNodes.keys(): if _any([parent.__class__ in self.removeNodes[node.__class__] for parent in node.parents]): if node.children and not _any([ parent.__class__ in ...
455,180
def test_fixTableColspans2(): '''http://es.wikipedia.org/w/index.php?title=Rep%C3%BAblica_Dominicana&oldid=36394218''' raw = r'''
def test_fixTableColspans2(): '''http://es.wikipedia.org/w/index.php?title=Rep%C3%BAblica_Dominicana&oldid=36394218''' raw = r'''
455,181
def create(): if current.start is None or current.endtitle is None: return False l1 = tokens[current.start].text.count("=") l2 = tokens[current.endtitle].text.count("=") level = min (l1, l2)
def create(): if current.start is None or current.endtitle is None: return False l1 = tokens[current.start].text.count("=") l2 = tokens[current.endtitle].text.count("=") level = min (l1, l2)
455,182
def create(): if current.start is None or current.endtitle is None: return False l1 = tokens[current.start].text.count("=") l2 = tokens[current.endtitle].text.count("=") level = min (l1, l2)
def create(): if current.start is None or current.endtitle is None: return False l1 = tokens[current.start].text.count("=") l2 = tokens[current.endtitle].text.count("=") level = min (l1, l2)
455,183
def login(self, username, password, domain=None): args = dict(action="login", lgname=username.encode("utf-8"), lgpassword=password.encode("utf-8"), format="json", ) if domain is not None: args['lgdomain'] = domain.encode('utf-8') headers = {"Content-Type": "application/x-www-form-urlencoded"} postdata = urllib.urlenco...
def login(self, username, password, domain=None, lgtoken=None): args = dict(action="login", lgname=username.encode("utf-8"), lgpassword=password.encode("utf-8"), format="json", ) if domain is not None: args['lgdomain'] = domain.encode('utf-8') headers = {"Content-Type": "application/x-www-form-urlencoded"} postdata = ...
455,184
def set_redirect_matcher(self, siteinfo): if 'general' in siteinfo and siteinfo['general'].get('sitename') == 'Wikipedia' and 'interwikimap' in siteinfo: fix_wikipedia_siteinfo(siteinfo) self.redirect_matcher = get_redirect_matcher(siteinfo, self)
def set_redirect_matcher(self, siteinfo): self.redirect_matcher = get_redirect_matcher(siteinfo, self)
455,185
def __init__(self, tree, save_reports=False, nesting_strictness='loose', status_cb=None): """Init with parsetree.
def __init__(self, tree, save_reports=False, nesting_strictness='loose', status_cb=None): """Init with parsetree.
455,186
def markInfoboxes(self, node): if node.__class__ == Article: tables = node.getChildNodesByClass(Table) found_infobox = False for table in tables: if miscutils.hasInfoboxAttrs(table): table.isInfobox = found_infobox = True if found_infobox or not tables: return if miscutils.articleStartsWithTable(node, max_text_until_in...
def markInfoboxes(self, node): if node.__class__ == Article: tables = node.getChildNodesByClass(Table) found_infobox = False for table in tables: if miscutils.hasInfoboxAttrs(table) and article_ns != 100: table.isInfobox = found_infobox = True if found_infobox or not tables: return if miscutils.articleStartsWithTable(n...
455,187
def markInfoboxes(self, node): if node.__class__ == Article: tables = node.getChildNodesByClass(Table) found_infobox = False for table in tables: if miscutils.hasInfoboxAttrs(table): table.isInfobox = found_infobox = True if found_infobox or not tables: return if miscutils.articleStartsWithTable(node, max_text_until_in...
def markInfoboxes(self, node): if node.__class__ == Article: tables = node.getChildNodesByClass(Table) found_infobox = False for table in tables: if miscutils.hasInfoboxAttrs(table): table.isInfobox = found_infobox = True if found_infobox or not tables: return if miscutils.articleStartsWithTable(node, max_text_until_in...
455,188
def __init__(self, tree, save_reports=False, nesting_strictness='loose', status_cb=None): """Init with parsetree.
def __init__(self, tree, save_reports=False, nesting_strictness='loose', status_cb=None): """Init with parsetree.
455,189
def fixReferenceNodes(self, node): ref_nodes = node.getChildNodesByClass(Reference) name2children = {} for ref_node in ref_nodes: ref_name = ref_node.attributes.get('name') if ref_name and ref_name != ref_name.strip('"'): ref_name = ref_name.strip('"') ref_node.vlist['name'] = ref_name if ref_name and ref_node.children...
deffixReferenceNodes(self,node):ref_nodes=node.getChildNodesByClass(Reference)name2children={}forref_nodeinref_nodes:ref_name=ref_node.attributes.get('name')ifref_nameandref_name!=ref_name.strip('"'):ref_name=ref_name.strip('"')ref_node.vlist['name']=ref_nameifref_nameandref_node.childrenandnotname2children.has_key(ref...
455,190
def removeBrokenChildren(self, node): """Remove Nodes (while keeping their children) which can't be nested with their parents.""" if node.__class__ in self.removeNodes.keys(): if _any([parent.__class__ in self.removeNodes[node.__class__] for parent in node.parents]): if node.children and not _any([ parent.__class__ in ...
def removeBrokenChildren(self, node): """Remove Nodes (while keeping their children) which can't be nested with their parents.""" if node.__class__ in self.removeNodes.keys(): if _any([parent.__class__ in self.removeNodes[node.__class__] for parent in node.parents]): if node.children and not _any([ parent.__class__ in ...
455,191
def fixReferenceNodes(self, node): ref_nodes = node.getChildNodesByClass(Reference) name2children = {} for ref_node in ref_nodes: ref_name = ref_node.attributes.get('name') if ref_name != ref_name.strip('"'): ref_name = ref_name.strip('"') ref_node.vlist['name'] = ref_name if ref_name and ref_node.children and not name...
def fixReferenceNodes(self, node): ref_nodes = node.getChildNodesByClass(Reference) name2children = {} for ref_node in ref_nodes: ref_name = ref_node.attributes.get('name') if ref_name and ref_name != ref_name.strip('"'): ref_name = ref_name.strip('"') ref_node.vlist['name'] = ref_name if ref_name and ref_node.children...
455,192
def removeAbsolutePositionedNode(self, node):
defremoveAbsolutePositionedNode(self,node):
455,193
def do_render(self, collection_id, post_data, is_new=False): metabook_data = post_data.get('metabook') if is_new and not metabook_data: return self.error_response('POST argument metabook or collection_id required') if not is_new and metabook_data: return self.error_response('Specify either metabook or collection_id, no...
def do_render(self, collection_id, post_data, is_new=False): metabook_data = post_data.get('metabook') if is_new and not metabook_data: return self.error_response('POST argument metabook or collection_id required') if not is_new and metabook_data: return self.error_response('Specify either metabook or collection_id, no...
455,194
def do_zip_post(self, collection_id, post_data, is_new=False): try: metabook_data = post_data['metabook'] except KeyError, exc: return self.error_response('POST argument required: %s' % exc) base_url = post_data.get('base_url') template_blacklist = post_data.get('template_blacklist', '') template_exclusion_category = ...
def do_zip_post(self, collection_id, post_data, is_new=False): try: metabook_data = post_data['metabook'] except KeyError, exc: return self.error_response('POST argument required: %s' % exc) base_url = post_data.get('base_url') template_blacklist = post_data.get('template_blacklist', '') template_exclusion_category = ...
455,195
def main(): application = Application() address = "localhost", 8899 server = WSGIServer(address, application, handler_class=handler) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "Bye bye"
def main(): application = Application() address = "localhost", 8899 server = WSGIServer(address, application) try: print "listening on %s:%d" % address server.serve_forever() except KeyboardInterrupt: server.stop() print "Bye bye"
455,196
def unNestEndingCellContent(self, node): '''http://de.wikipedia.org/w/index.php?title=Bahnstrecke_Berlin%E2%80%93Dresden&oldid=72891289''' if node.__class__ == Table and not node.getParentNodesByClass(Table): last_row = node.children[-1] if not last_row or len(last_row.children) != 1: return last_cell = last_row.child...
def unNestEndingCellContent(self, node): '''http://de.wikipedia.org/w/index.php?title=Bahnstrecke_Berlin%E2%80%93Dresden&oldid=72891289''' if node.__class__ == Table and not node.getParentNodesByClass(Table): last_row = node.children[-1] if not last_row or len(last_row.children) != 1: return last_cell = last_row.child...
455,197
def create_ref(self, name, vlist, inner, xopts): expander = xopts.expander if expander is not None and inner: inner = expander.parseAndExpand(inner, True)
def create_ref(self, name, vlist, inner, xopts): expander = xopts.expander if expander is not None and inner: inner = expander.parseAndExpand(inner, True)
455,198
def removeSeeAlso(self, node): try: seealso_section = _('See also') except NameError: seealso_section = 'See also'
def removeSeeAlso(self, node): try: seealso_section = _('See also') except NameError: seealso_section = 'See also'
455,199