rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
_, rf, ef = os.popen3(cmd) | sf, rf, ef = os.popen3(cmd) sf.close() errors = ef.read() stdout_data = rf.read() | def run_command(cmd, *args): if not cmd: return '' if args: cmd = ' '.join((cmd,) + args) try: import subprocess except ImportError: # Python 2.3 _, rf, ef = os.popen3(cmd) else: # Python 2.4+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) rf, ef = p.stdout, p.stderr errors = ef.r... |
rf, ef = p.stdout, p.stderr errors = ef.read() | stdout_data, errors = p.communicate() | def run_command(cmd, *args): if not cmd: return '' if args: cmd = ' '.join((cmd,) + args) try: import subprocess except ImportError: # Python 2.3 _, rf, ef = os.popen3(cmd) else: # Python 2.4+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) rf, ef = p.stdout, p.stderr errors = ef.r... |
return decode_input(rf.read()).strip() | return decode_input(stdout_data).strip() | def run_command(cmd, *args): if not cmd: return '' if args: cmd = ' '.join((cmd,) + args) try: import subprocess except ImportError: # Python 2.3 _, rf, ef = os.popen3(cmd) else: # Python 2.4+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) rf, ef = p.stdout, p.stderr errors = ef.r... |
__LXML_VERSION = open(os.path.join(get_base_dir(), 'version.txt')).read().strip() | f = open(os.path.join(get_base_dir(), 'version.txt')) try: __LXML_VERSION = f.read().strip() finally: f.close() | def version(): global __LXML_VERSION if __LXML_VERSION is None: __LXML_VERSION = open(os.path.join(get_base_dir(), 'version.txt')).read().strip() return __LXML_VERSION |
def __init__(self): | def __init__(self, *args, **kwargs): | def __init__(self): html_builder = etree_builders.getETreeModule(html, fullTree=False) etree_builder = etree_builders.getETreeModule(etree, fullTree=False) self.elementClass = html_builder.Element self.commentClass = etree_builder.Comment _base.TreeBuilder.__init__(self) |
_base.TreeBuilder.__init__(self) | _base.TreeBuilder.__init__(self, *args, **kwargs) | def __init__(self): html_builder = etree_builders.getETreeModule(html, fullTree=False) etree_builder = etree_builders.getETreeModule(etree, fullTree=False) self.elementClass = html_builder.Element self.commentClass = etree_builder.Comment _base.TreeBuilder.__init__(self) |
will be created to encapsulate the HTML in a single element. | will be created to encapsulate the HTML in a single element. In this case, leading or trailing text is allowed. | def fragment_fromstring(html, create_parent=False, base_url=None, parser=None, **kw): """ Parses a single HTML element; it is an error if there is more than one element, or if anything but whitespace precedes or follows the element. If create_parent is true (or is a tag name) then a parent node will be created to enca... |
return fragment_fromstring('<%s>%s</%s>' % ( create_parent, html, create_parent), parser=parser, base_url=base_url, **kw) elements = fragments_fromstring(html, parser=parser, no_leading_text=True, base_url=base_url, **kw) | new_root = Element(create_parent) if elements: if isinstance(elements[0], basestring): new_root.text = elements[0] del elements[0] new_root.extend(elements) return new_root | def fragment_fromstring(html, create_parent=False, base_url=None, parser=None, **kw): """ Parses a single HTML element; it is an error if there is more than one element, or if anything but whitespace precedes or follows the element. If create_parent is true (or is a tag name) then a parent node will be created to enca... |
raise etree.ParserError( "No elements found") | raise etree.ParserError('No elements found') | def fragment_fromstring(html, create_parent=False, base_url=None, parser=None, **kw): """ Parses a single HTML element; it is an error if there is more than one element, or if anything but whitespace precedes or follows the element. If create_parent is true (or is a tag name) then a parent node will be created to enca... |
etree.XPath.__init__(self, path) | etree.XPath.__init__(self, path, namespaces=namespaces) | def __init__(self, css): path = css_to_xpath(css) etree.XPath.__init__(self, path) self.css = css |
versions.append((map(tryint, version_string.split('.')), | versions.append((tuple(map(tryint, version_string.split('.'))), | def download_library(dest_dir, location, name, version_re, filename, version=None): if version is None: try: fns = ftp_listdir(location) versions = [] for fn in fns: match = version_re.search(fn) if match: version_string = match.group(1) versions.append((map(tryint, version_string.split('.')), version_string)) if versi... |
except Exception, e: | except Exception: | def __init__(self, etree=None, file=None, include=True, expand=True, include_params={}, expand_params={}, compile_params={}, store_schematron=False, store_xslt=False, store_report=False, phase=None): super(Schematron, self).__init__() |
"No tree or file given: %s" % e) | "No tree or file given: %s" % sys.exc_info()[1]) | def __init__(self, etree=None, file=None, include=True, expand=True, include_params={}, expand_params={}, compile_params={}, store_schematron=False, store_xslt=False, store_report=False, phase=None): super(Schematron, self).__init__() |
def add_metadata(self, environ, auth): | def add_metadata(self, environ, identity): | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
It modifies the C{auth} dictionary to add the metadata. | It modifies the C{identity} dictionary to add the metadata. | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
@param auth: The repoze.who's auth dictionary. | @param identity: The repoze.who's identity dictionary. | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
auth.get('repoze.who.userid'), | identity.get('repoze.who.userid'), | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
for (dn, attributes) in self.ldap_connection.search_s(*args): auth.update(attributes) | attributes = self.ldap_connection.search_s(*args) identity.update(attributes) | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
environ['repoze.who.logger'].warn('Cannot add metadata: %s' % \ msg) return | environ['repoze.who.logger'].warn('Cannot add metadata: %s' % msg) | def add_metadata(self, environ, auth): """ Add metadata about the authenticated user to the auth. It modifies the C{auth} dictionary to add the metadata. @param environ: The WSGI environment. @param auth: The repoze.who's auth dictionary. """ # Search arguments: args = ( auth.get('repoze.who.userid'), ldap.SCOPE_BAS... |
if (len(entry.content) > 0): | if (entry.has_key("content") and len(entry.content) > 0): | def post(self): """ Use feedparser to queue any blog posts from the given URL since the given timestamp """ |
"publishTime": unicode(publish_time.isoformat()).encode("utf-8")} | } | def post(self): """Publish the given blog post to the configured Ning Network""" |
return logging.info("Dequeued: \"%s\" %s" % (blog_parts["title"], publish_time.ctime())) | raise | def post(self): """Publish the given blog post to the configured Ning Network""" |
logging.debug("Stopping processing with: \"%s\" @ ", (entry.title, entry_datetime.ctime())) | logging.debug("Stopping processing with: \"%s\" @ " % (entry.title, entry_datetime.ctime())) | def post(self): """ Use feedparser to queue any blog posts from the given URL since the given timestamp """ |
logging.info("Queued feed: \"%s\" %s" % | logging.debug("Queued feed: \"%s\" %s" % | def get(self): """ Query the DB and queue any feeds that haven't been processed since update_interval """ |
logging.info("Dequeued feed: \"%s\"" % (feed.url)) | logging.debug("Dequeued feed: \"%s\"" % (feed.url)) | def post(self): """ Use feedparser to save any blog posts from the given URL since the given timestamp """ |
logging.error("Exception when fetching feed: \"%s\" %s" % | logging.warn("Exception when fetching feed: \"%s\" %s" % | def post(self): """ Use feedparser to save any blog posts from the given URL since the given timestamp """ |
logging.error("Unable to fetch feed: (%s) \"%s\"" % | logging.warn("Unable to fetch feed: (%s) \"%s\"" % | def post(self): """ Use feedparser to save any blog posts from the given URL since the given timestamp """ |
logging.info("Queued entry: \"%s\" %s" % | logging.debug("Queued entry: \"%s\" %s" % | def get(self): """ Query the DB and queue any entries that haven't been uploaded yet """ |
logging.info("Dequeued: \"%s\" %s" % (entry.title, | logging.debug("Dequeued entry: \"%s\" %s" % (entry.title, | def post(self): """Publish the given blog post to the configured Ning Network""" |
logging.warn("No credentials found for %s" % entry.owner) | logging.error("No credentials found for %s" % entry.owner) | def post(self): """Publish the given blog post to the configured Ning Network""" |
logging.debug("Stopping processing with: \"%s\" @ " % | logging.debug("Stopping processing with: \"%s\" @ %s" % | def post(self): """ Use feedparser to queue any blog posts from the given URL since the given timestamp """ |
taskqueue.add(url="/blogs/photo/consumer", | taskqueue.add(url="/blogs/entry/consumer", | def post(self): """ Use feedparser to queue any blog posts from the given URL since the given timestamp """ |
('/blogs/photo/consumer', EntryConsumer), | ('/blogs/entry/consumer', EntryConsumer), | def main(): application = webapp.WSGIApplication([ ('/blogs/feed/producer', FeedProducer), ('/blogs/feed/consumer', FeedConsumer), ('/blogs/photo/consumer', EntryConsumer), ('/blogs/admin/new', FeedConfig), ('/blogs/admin/view', FeedBrowser), ], debug=True) util.run_wsgi_app(application) |
e.title = truncate.smart_truncate (strip_tags (e.content)) | e.title = truncate.smart_truncate (strip_tags (e.content)).strip () | def share (self, args={}): content = args.get ('content', '') id = args.get ('id', None) title = args.get ('title', None) link = args.get ('link', None) images = args.get ('images', None) files = args.get ('files', MultiValueDict ()) source = args.get ('source', '') user = args.get ('user', None) |
e.title = truncate.smart_truncate (strip_tags (content)) | e.title = truncate.smart_truncate (strip_tags (content)).strip () | def share (self, args={}): content = args.get ('content', '') id = args.get ('id', None) title = args.get ('title', None) link = args.get ('link', None) images = args.get ('images', None) files = args.get ('files', MultiValueDict ()) source = args.get ('source', '') user = args.get ('user', None) |
if mblob and 'content' in mblob: return mblob | if mblob: if isinstance (mblob, types.StringType) or \ isinstance (mblob, types.UnicodeType): mblob = json.loads (mblob) if 'content' in mblob: return mblob | def mrss_init (mblob=None): if mblob and 'content' in mblob: return mblob return {'content': []} |
__su_subs, text) | __su_subs, smart_unicode (text)) | def shorturls (text): """Expand short URLs.""" return re.sub (r'http://(tinyurl.com|bit.ly|goo.gl|url4.eu|is.gd|ur1.ca|2tu.us|ff.im|post.ly|awe.sm|lnk.ms|pic.gd|tl.gd|vid.ly)(/\w+)', __su_subs, text) |
s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', | s = re.sub (r'http://(www\.)?youtube\.com/watch\?v=([\-\w]+)(\S*)', | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) | s = re.sub (r'http://(www\.)?vimeo\.com/(\d+)', __sv_vimeo, s) | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://www.ustream.tv/recorded/(\d+)', __sv_ustream, s) | s = re.sub (r'http://www\.ustream\.tv/recorded/(\d+)', __sv_ustream, s) | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://www.dailymotion.[a-z]{2,3}/video/([\-\w]+)_(\S*)', | s = re.sub (r'http://www\.dailymotion\.[a-z]{2,3}/video/([\-\w]+)_(\S*)', | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://www.metacafe.com/(w|watch)/(\d+)/(\S*)', | s = re.sub (r'http://www\.metacafe\.com/(w|watch)/(\d+)/(\S*)', | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://(www\.)?twitvid.com/(\w+)', __sv_twitvid, s) | s = re.sub (r'http://(www\.)?twitvid\.com/(\w+)', __sv_twitvid, s) | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://www.collegehumor.com/video:(\d+)', __sv_chtv, s) | s = re.sub (r'http://www\.collegehumor\.com/video:(\d+)', __sv_chtv, s) | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
s = re.sub (r'http://video.google.com/videoplay\?docid=(\d+)(\S*)', | s = re.sub (r'http://video\.google\.com/videoplay\?docid=(\d+)(\S*)', | def videolinks (s): """Expand video links.""" if 'youtube.com/' in s: s = re.sub (r'http://(www\.)?youtube.com/watch\?v=([\-\w]+)(\S*)', __sv_youtube, s) if 'vimeo.com/' in s: s = re.sub (r'http://(www\.)?vimeo.com/(\d+)', __sv_vimeo, s) if 'http://www.ustream.tv/recorded/' in s: s = re.sub (r'http://www.ustream.tv/rec... |
url = '[GLS-UPLOAD]/%s' % file.url.replace ('/upload/', '') | url = '[GLS-UPLOAD]/%s' % file.name.replace ('upload/', '') | def downsave_uploaded_image (file): url = '[GLS-UPLOAD]/%s' % file.url.replace ('/upload/', '') try: thumb = get_thumb_info (hashlib.sha1 (file.name).hexdigest ()) if not os.path.isfile (thumb['local']): shutil.copy (file.path, thumb['local']) downscale_image (thumb['local']) return (thumb['internal'], url) except: pas... |
e.link = link if link else settings.BASE_URL | e.link = link if link else settings.BASE_URL + '/' | def share (self, args={}): content = args.get ('content', '') id = args.get ('id', None) title = args.get ('title', None) link = args.get ('link', None) images = args.get ('images', None) files = args.get ('files', MultiValueDict ()) source = args.get ('source', '') user = args.get ('user', None) |
e.link = settings.BASE_URL | e.link = settings.BASE_URL + '/' | def reshare (self, entry, args={}): id = args.get ('id', None) as_me = int (args.get ('as_me', False)) user = args.get ('user', None) |
self.start() | def __call__(self, iterable): try: self.maxval = len(iterable) except TypeError: # If the iterable has no length, then rely on the value provided # by the user, otherwise fail. if not (isinstance(self.maxval, (int, long)) and self.maxval > 0): raise RuntimeError('Could not determine maxval from iterable. ' 'You must ex... | |
self.update(self.currval + 1) | if self.start_time is None: self.start() else: self.update(self.currval + 1) | def next(self): try: next = self._iterable.next() self.update(self.currval + 1) return next except StopIteration: self.finish() raise |
self.fillchar = ' ' | self.fillchar = fillchar | def __init__(self, marker='#', left='|', right='|', fillchar=' '): self.marker = marker self.left = left self.right = right self.fillchar = ' ' |
query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s\'' % predir.upper() if suffix: query += ' and suffix=\'%s\'' % predir.upper() if postdir: query += ' and po... | query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=%s' params = [street.upper()] if predir: query += ' and predir=%s' params.apepnd(predir.upper()) if suffix: query += ' and suffix=%s' params.append(suffix.upper()) if pos... | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
query += ' and (left_city=\'%s\' or right_city=\'%s\')' % cu | query += ' and (left_city=%s or right_city=%s)' params.extend([cu, cu]) | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
query += ' and (left_state=\'%s\' or right_state=\'%s\')' % su | query += ' and (left_state=%s or right_state=%s)' params.extend([su, su]) | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
query += ' and (left_zip=\'%s\' or right_zip=\'%s\')' % zipcode | query += ' and (left_zip=%s or right_zip=%s)' params.extend([zipcode, zipcode]) | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
query += ' and from_num <= %d and to_num >= %d' % (number, number) | query += ' and from_num <= %d and to_num >= %d' params.extend([number, number]) | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
cursor.execute(query) | cursor.execute(query, tuple(params)) | def search(self,street,number=None,predir=None,suffix=None,postdir=None,city=None,state=None,zipcode=None): query = 'select id, pretty_name, from_num, to_num, left_from_num, left_to_num, right_from_num, right_to_num, ST_AsEWKT(geom) from blocks where street=\'%s\'' % street.upper() if predir: query += ' and predir=\'%s... |
from ebpub.geocoder.parser.parsing import normalize | from parser.parsing import normalize | def save(self): if not self.normalized_name: from ebpub.geocoder.parser.parsing import normalize self.normalized_name = normalize(self.pretty_name) super(Place, self).save() |
def __init__(self,conn): self.connection = conn def close(self): self.connection.close() def search(self, predir_a=None, street_a=None, suffix_a=None, postdir_a=None, predir_b=None, street_b=None, suffix_b=None, postdir_b=None): cursor = self.connection.cursor() query = 'select id, pretty_name, ST_AsEWKT(location) from... | def __init__(self,conn): self.connection = conn def close(self): self.connection.close() def search(self, predir_a=None, street_a=None, suffix_a=None, postdir_a=None, predir_b=None, street_b=None, suffix_b=None, postdir_b=None): cursor = self.connection.cursor() query = 'select id, pretty_name, ST_AsEWKT(location) from... | def __init__(self,conn): self.connection = conn |
cursor.execute(query, params) results = cursor.fetchall() cursor.close() return results | print query print filters cursor.execute(query, params) results = cursor.fetchall() cursor.close() return results | def search(self, predir_a=None, street_a=None, suffix_a=None, postdir_a=None, predir_b=None, street_b=None, suffix_b=None, postdir_b=None): cursor = self.connection.cursor() query = 'select id, pretty_name, ST_AsEWKT(location) from intersections' filters = [] params = [] if predir_a: filter.append('(predir_a=%s OR pred... |
except Exception, e: | except DoesNotExist, e: | def _db_lookup(self, street_a, street_b): try: searcher = PostgisIntersectionSearcher(self.connection) intersections = searcher.search( predir_a=street_a['pre_dir'], street_a=street_a['street'], suffix_a=street_a['suffix'], postdir_a=street_a['post_dir'], predir_b=street_b['pre_dir'], street_b=street_b['street'], suffi... |
self.connection.close() | pass | def close(self): self.connection.close() |
class PostgisIntersectionGeocoder(Geocoder): def __init__(self, cxn): self.connection = cxn self.spelling = SpellingCorrector() | class PostgisIntersectionGeocoder: def __init__(self, cxn): self.connection = cxn self.spelling = SpellingCorrector() | def _build_result(self, location, block, geocoded_pt): |
'cp -u "%s" "%s"' % (join(self.dir1.rootdir, path), join(self.dir2.rootdir, path)) | 'cp -f --preserve=all "%s" "%s"' % (join(self.dir1.rootdir, path), join(self.dir2.rootdir, path)) | def on_compare(self, path, kind, result): from os.path import join |
) elif result == CompareBase.MISSING2: if kind == 'f': self.cpfiles.append( 'cp "%s" "%s"' % (join(self.dir1.rootdir, path), join(self.dir2.rootdir, path)) | def on_compare(self, path, kind, result): from os.path import join | |
'rm "%s"' % join(self.dir2.rootdir, path) | 'rm -f "%s"' % join(self.dir2.rootdir, path) | def on_compare(self, path, kind, result): from os.path import join |
'rmdir -p "%s"' % join(self.dir2.rootdir, path) | 'rmdir "%s"' % join(self.dir2.rootdir, path) | def on_compare(self, path, kind, result): from os.path import join |
'echo copy %s' % path | 'echo copy "%s"' % path | def on_compare(self, path, kind, result): from os.path import join |
'echo "copy %s"' % path | 'echo copy "%s"' % path | def on_compare(self, path, kind, result): from os.path import join |
'echo del %s' % path | 'echo del "%s"' % path | def on_compare(self, path, kind, result): from os.path import join |
try: discussions=pd.getDiscussionFor(item) num_discussions=discussions.replyCount(item) return num_discussions except DiscussionNotAllowed: | if not pd.isDiscussionAllowedFor: | def getCommentsLen(self,item): """ Return the number of comments of the object """ pd = getToolByName(self.context, 'portal_discussion', None) try: discussions=pd.getDiscussionFor(item) num_discussions=discussions.replyCount(item) return num_discussions except DiscussionNotAllowed: return 0 |
var.setProperty('long_name','%s - %s' % (var1.getLongName(),var2.getLongName())) var.setProperty('units',str(unit)) | var.setProperty('long_name',xmlstore.util.unicode2ascii('%s - %s' % (var1.getLongName(),var2.getLongName()))) var.setProperty('units',xmlstore.util.unicode2ascii(unit)) | def compseries(path1,exp1,path2,exp2,dump=None,quiet=False,order=1): """Compares two data series that reside in NetCDF files. Series are expressions that can contain NetCDF variables as well as constants and many NumPy functions. The first series is used as reference, and the second series is interpolated to the first... |
var.setProperty('long_name',str(var1.getLongName())) var.setProperty('units',str(var1.getUnit())) var.setProperty('source',str(path1)) var.setProperty('expression',str(var1.getName())) | var.setProperty('long_name',xmlstore.util.unicode2ascii(var1.getLongName())) var.setProperty('units',xmlstore.util.unicode2ascii(var1.getUnit())) var.setProperty('source',xmlstore.util.unicode2ascii(path1)) var.setProperty('expression',xmlstore.util.unicode2ascii(var1.getName())) | def compseries(path1,exp1,path2,exp2,dump=None,quiet=False,order=1): """Compares two data series that reside in NetCDF files. Series are expressions that can contain NetCDF variables as well as constants and many NumPy functions. The first series is used as reference, and the second series is interpolated to the first... |
var.setProperty('long_name',str(var2.getLongName())) var.setProperty('units',str(var2.getUnit())) var.setProperty('source',str(path2)) var.setProperty('expression',str(var2.getName())) | var.setProperty('long_name',xmlstore.util.unicode2ascii(var2.getLongName())) var.setProperty('units',xmlstore.util.unicode2ascii(var2.getUnit())) var.setProperty('source',xmlstore.util.unicode2ascii(path2)) var.setProperty('expression',xmlstore.util.unicode2ascii(var2.getName())) | def compseries(path1,exp1,path2,exp2,dump=None,quiet=False,order=1): """Compares two data series that reside in NetCDF files. Series are expressions that can contain NetCDF variables as well as constants and many NumPy functions. The first series is used as reference, and the second series is interpolated to the first... |
if options.debug: | try: | def newexpression(option, opt_str, value, parser): if parser.values.lastsource is None: raise optparse.OptionValueError('%s must be preceded by a -s/--source option.' % option) if not isinstance(value,tuple): value = (None,value) parser.values.expressions.append((value[0],parser.values.lastsource,value[1])) |
else: try: plt.plot() except Exception,e: print e return 1 | except Exception,e: if options.debug: raise print e return 1 | def newexpression(option, opt_str, value, parser): if parser.values.lastsource is None: raise optparse.OptionValueError('%s must be preceded by a -s/--source option.' % option) if not isinstance(value,tuple): value = (None,value) parser.values.expressions.append((value[0],parser.values.lastsource,value[1])) |
print 'Error: "%s" does not contain = and therefore cannot be a dimension re-assignment. Dimension reassignments must be specified as OLDDIMENSIONNAME=NEWDIMENSIONNAME.' % assign | print 'Error: "%s" does not contain = and therefore cannot be a dimension reassignment. Dimension reassignments must be specified as OLDDIMENSIONNAME=NEWDIMENSIONNAME.' % assign | def newexpression(option, opt_str, value, parser): if parser.values.lastsource is None: raise optparse.OptionValueError('%s must be preceded by a -s/--source option.' % option) if not isinstance(value,tuple): value = (None,value) parser.values.expressions.append((value[0],parser.values.lastsource,value[1])) |
print ('Bias = %s %s' % (mean2-mean1,unit)).encode('utf-8') print ('RMSE = %s %s' % (numpy.sqrt((delta**2).mean()),unit)).encode('utf-8') print ('MAE = %s %s' % (numpy.abs(delta).mean(),unit)).encode('utf-8') | print ('Bias = %s %s' % (mean2-mean1,unit)).encode(enc,'ignore') print ('RMSE = %s %s' % (numpy.sqrt((delta**2).mean()),unit)).encode(enc,'ignore') print ('MAE = %s %s' % (numpy.abs(delta).mean(),unit)).encode(enc,'ignore') | def compseries(path1,exp1,path2,exp2,dump=None,quiet=False,order=1): """Compares two data series that reside in NetCDF files. Series are expressions that can contain NetCDF variables as well as constants and many NumPy functions. The first series is used as reference, and the second series is interpolated to the first... |
else: | elif self.settings['WindowPosition/Width'].getValue(): | def hideEvent(self,event): self.emit(QtCore.SIGNAL('hidden()')) |
try: print s except UnicodeEncodeError: print s.encode('utf-8') | print s.encode(enc) | def printfn(s): try: print s except UnicodeEncodeError: print s.encode('utf-8') |
def originate(self, cld, timeout, sip_proxy, cli, app, app_data, md5secret = None, authname = None, action_id = None, action_listener = None, password = None, call_id = None, codecs = "g729,ulaw,alaw", vars = []): | def originate(self, cld, timeout, sip_proxy, cli, app, app_data, md5secret = None, authname = None, action_id = None, action_listener = None, password = None, call_id = None, codecs = "g729,ulaw,alaw", _vars = []): | def originate(self, cld, timeout, sip_proxy, cli, app, app_data, md5secret = None, authname = None, action_id = None, action_listener = None, password = None, call_id = None, codecs = "g729,ulaw,alaw", vars = []): |
self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(query[1])) | self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(DamnUnicode(query[1]))) | def run(self): while self.queries is None: time.sleep(.025) try: self.parent.loadlevel += 1 except: pass # Window might have been closed while len(self.queries): query = self.queries[0] if query[0] == 'feed': self.returnResult(DV.youtube_service.GetYouTubeVideoFeed(query[1])) elif query[0] == 'image': http = DamnURLOpe... |
Damnlog('YouTube browser search box populating complete, beginning actual search for', search,'at URL:',prefix + urllib2.quote(search)) self.getService().query(('feed', prefix + urllib2.quote(search))) | Damnlog('YouTube browser search box populating complete, beginning actual search for', search, 'at URL:', prefix + urllib2.quote(search)) self.getService().query(('feed', DamnUnicode(prefix + urllib2.quote(search)))) | def search(self, event=None, search=u''): Damnlog('YouTube browser is now searching for', search, 'from event', event) self.scrollpanel.Hide() self.waitingpanel.Show() self.toppanel.Layout() if not search: search = self.searchbox.GetValue() if not search: return search=DamnUnicode(search) self.searchbutton.LoadFile(DV.... |
os.makedirs(DV.conf_file_directory) | try: os.makedirs(DV.conf_file_directory) except: DV.conf_file_directory = DV.actual_conf_file_directory try: os.makedirs(DV.conf_file_directory) except: print 'Cannot create configuration directory!' pass | def DamnOpenFile(f, m): f = DamnUnicode(f) try: return open(f, m) except: try: return open(f.encode('utf8'), m) except: try: return open(f.encode('windows-1252'), m) except: return open(f.encode('utf8', 'ignore'), m) |
DV.tmp_path = DamnUnicode(DV.conf_file_directory + u'temp/'.replace(u'/', DV.sep)) | DV.tmp_path = DamnUnicode(DV.actual_conf_file_directory + u'temp/'.replace(u'/', DV.sep)) if not os.path.exists(DV.tmp_path): os.makedirs(DV.tmp_path) | def DamnSysinfo(): try: sysinfo = u'DamnVid version: ' + DV.version + u'\nDamnVid mode: ' if DV.bit64: sysinfo += u'64-bit' else: sysinfo += u'32-bit' sysinfo += u'\nDamnVid arguments: ' if len(sys.argv[1:]): sysinfo += DamnUnicode(' '.join(sys.argv[1:])) else: sysinfo += u'(None)' sysinfo += u'\nMachine name: ' if len... |
title = DamnHyperlink(tmppanel, -1, self.cleanString(results.entry[i].media.title.text), self.cleanString(results.entry[i].media.player.url), wx.WHITE) | tmpTitle = self.cleanString(results.entry[i].media.title.text) title = DamnHyperlink(tmppanel, -1, tmpTitle, self.cleanString(results.entry[i].media.player.url), wx.WHITE) while title.GetBestSizeTuple()[0] > 208: try: title.Destroy() except: Damnlog('!Failed to destroy old title hyperlink while attempting to fit it ins... | def onLoad(self, event): info = event.GetInfo() Damnlog('onLoad event on YouTube browser. Event data:', info) if info['query'][0] == 'feed': results = info['result'] boldfont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) boldfont.SetWeight(wx.FONTWEIGHT_BOLD) tmpscrollbar = wx.ScrollBar(self.resultpanel, -1, sty... |
progress = min((100.0, copied / total * 100.0)) | progress = max(0.0, min(100.0, copied / total * 100.0)) | def run(self): self.uris = self.getURI(self.sourceuri) self.abort = False if not self.abort: if True: Damnlog('Conversion routine starting, URI is', self.uris[0]) self.uri = self.uris[0] self.update(0) self.parent.thisvideo.append(self.parent.videos[self.parent.converting]) self.filename = unicodedata.normalize('NFKD',... |
'progress':min(100.0, float(float(res.group(1)) / self.duration / float(self.totalpasses) + float(float(self.passes - 1) / float(self.totalpasses))) * 100.0), 'status':self.parent.meta[self.parent.videos[self.parent.converting]]['status'] + ' [' + str(int(100.0 * float(res.group(1)) / self.duration)) + '%]' | 'progress': progress, 'status': self.parent.meta[self.parent.videos[self.parent.converting]]['status'] + ' [' + str(int(progress)) + '%]' | def parseLine(self, line): Damnlog('ffmpeg>', line) if self.duration == None: res = REGEX_FFMPEG_DURATION_EXTRACT.search(line) if res: self.duration = int(res.group(1)) * 3600 + int(res.group(2)) * 60 + float(res.group(3)) if not self.duration: self.duration = None else: res = REGEX_FFMPEG_TIME_EXTRACT.search(line) if ... |
s.append(i.replace('?DAMNVID_VIDEO_STREAM?', '-').replace('?DAMNVID_VIDEO_PASS?', str(self.passes)).replace('?DAMNVID_OUTPUT_FILE?', DV.tmp_path + self.tmpfilename)) | s.append(i.replace('?DAMNVID_VIDEO_STREAM?', stream).replace('?DAMNVID_VIDEO_PASS?', str(self.passes)).replace('?DAMNVID_OUTPUT_FILE?', DV.tmp_path + self.tmpfilename)) | def cmd2str(self, cmd): s = [] for i in cmd: s.append(i.replace('?DAMNVID_VIDEO_STREAM?', '-').replace('?DAMNVID_VIDEO_PASS?', str(self.passes)).replace('?DAMNVID_OUTPUT_FILE?', DV.tmp_path + self.tmpfilename)) return s |
else: self.feeder = DamnStreamCopy(self.stream, self.process.stdin) self.feeder.start() | def run(self): self.uris = self.getURI(self.sourceuri) self.abort = False if not self.abort: if True: Damnlog('Conversion routine starting, URI is', self.uris[0]) self.uri = self.uris[0] self.update(0) self.parent.thisvideo.append(self.parent.videos[self.parent.converting]) self.filename = unicodedata.normalize('NFKD',... | |
except: Damnlog('Stream copy: failed to write', len(i), 'bytes to output stream.') | except Exception, e: Damnlog('Stream copy: failed to write', len(i), 'bytes to output stream:',e) | def run(self): firstread = True firstwrite = True Damnlog('Stream copy: Begin') i = 'Let\'s go' while len(i): try: i = self.s1.read(self.buffer) if firstread: Damnlog('Stream copy: first read successful, read', len(i), 'bytes.') firstread = False try: self.s2.write(i) if firstwrite: Damnlog('Stream copy: first write su... |
Damnlog('Stream copy: Filed to read from input stream.') | Damnlog('Stream copy: Failed to read from input stream.') | def run(self): firstread = True firstwrite = True Damnlog('Stream copy: Begin') i = 'Let\'s go' while len(i): try: i = self.s1.read(self.buffer) if firstread: Damnlog('Stream copy: first read successful, read', len(i), 'bytes.') firstread = False try: self.s2.write(i) if firstwrite: Damnlog('Stream copy: first write su... |
lastx = DV.prefs.gets('damnvid-mainwindow','lastx') lasty = DV.prefs.gets('damnvid-mainwindow','lasty') lastw = DV.prefs.gets('damnvid-mainwindow','lastw') lasth = DV.prefs.gets('damnvid-mainwindow','lasth') lastresw = DV.prefs.gets('damnvid-mainwindow','lastresw') lastresh = DV.prefs.gets('damnvid-mainwindow','lastres... | allstuff=( DV.prefs.gets('damnvid-mainwindow','lastx'), DV.prefs.gets('damnvid-mainwindow','lasty'), DV.prefs.gets('damnvid-mainwindow','lastw'), DV.prefs.gets('damnvid-mainwindow','lasth'), DV.prefs.gets('damnvid-mainwindow','lastresw'), DV.prefs.gets('damnvid-mainwindow','lastresh') ) | def init2(self): Damnlog('Starting DamnMainFrame init stage 2.') if os.path.exists(DV.conf_file_directory + 'lastversion.damnvid'): lastversion = DamnOpenFile(DV.conf_file_directory + 'lastversion.damnvid', 'r') dvversion = lastversion.readline().strip() lastversion.close() del lastversion Damnlog('Version file found; ... |
elif allstuff[0] < 0 or allstuff[0] + allstuff[2] >= lastresw or allstuff[1] < 0 or allstuff[1] + allstuff[3] >= lasth: | elif allstuff2[0] < 0 or allstuff2[0] + allstuff2[2] >= allstuff2[4] or allstuff2[1] < 0 or allstuff2[1] + allstuff2[3] >= allstuff2[5]: | def init2(self): Damnlog('Starting DamnMainFrame init stage 2.') if os.path.exists(DV.conf_file_directory + 'lastversion.damnvid'): lastversion = DamnOpenFile(DV.conf_file_directory + 'lastversion.damnvid', 'r') dvversion = lastversion.readline().strip() lastversion.close() del lastversion Damnlog('Version file found; ... |
required_files.append(forkFolder + ':' + f) | appendToList(forkFolder + ':' + f) | def addFile(*args): global required_files, forkFolder for f in args: if forkFolder is not None: if os.path.exists(forkFolder + f): required_files.append(forkFolder + ':' + f) else: required_files.append(f) else: required_files.append(f) |
required_files.append(f) | appendToList(f) | def addFile(*args): global required_files, forkFolder for f in args: if forkFolder is not None: if os.path.exists(forkFolder + f): required_files.append(forkFolder + ':' + f) else: required_files.append(f) else: required_files.append(f) |
required_dirs=['img','conf','locale','ui','socks'] | required_dirs=['img', 'conf', 'locale'] required_modules=['socks', 'ui'] | def addFile(*args): global required_files, forkFolder for f in args: if forkFolder is not None: if os.path.exists(forkFolder + f): required_files.append(forkFolder + ':' + f) else: required_files.append(f) else: required_files.append(f) |
if f.find('.svn')==-1 and f.find('LICENSE')==-1 and f.find('.psd')==-1 and f.find('.noinclude')==-1 and f.find('.module.damnvid')==-1 and f.find('.bmp')==-1 and f.find('.ai')==-1 and f.find('.exe')==-1 and f.find('.zip')==-1 and f.find('fireworks.png')==-1: | if goodFile(f): | def addDir(d): for f in os.listdir(d): if f.find('.svn')==-1 and f.find('LICENSE')==-1 and f.find('.psd')==-1 and f.find('.noinclude')==-1 and f.find('.module.damnvid')==-1 and f.find('.bmp')==-1 and f.find('.ai')==-1 and f.find('.exe')==-1 and f.find('.zip')==-1 and f.find('fireworks.png')==-1: if os.path.isdir(d+os.s... |
if OSNAME != 'posix': | if OSNAME != 'posix' or not goodFile(f): | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
for i in glob.glob(f): | for i in os.listdir(f): | def addModule(f, recursive=True): if OSNAME != 'posix': return if os.path.isdir(f): for i in glob.glob(f): if os.path.isdir(f + os.sep + i) and recursive: addModule(f + os.sep + i) elif i[-3:] == '.py': addModule(f + os.sep + i) elif f[-3:] == '.py': try: py_compile.compile(f) if os.path.exists(f+'o'): addFile(f+'o') a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.