rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
MSG("Done.")
def cmd_init(argv, path_to_tx=None): """ Initialize the tx client folder. The .tx folder is created by default to the CWD! """ # Current working dir path root = os.getcwd() if path_to_tx: if not os.path.exists(path_to_tx): MSG("tx: The path to root directory does not exist!") return path = find_dot_tx(path_to_tx) if...
'meta': { 'project_name': project_info['name'],
'meta': { 'root_dir': os.path.abspath(root),
def cmd_init(argv, path_to_tx=None): """ Initialize the tx client folder. The .tx folder is created by default to the CWD! """ # Current working dir path root = os.getcwd() if path_to_tx: if not os.path.exists(path_to_tx): MSG("tx: The path to root directory does not exist!") return path = find_dot_tx(path_to_tx) if...
expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*%s.*' % expr_re)
expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*%s' % expr_re)
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
By default, the command will print `set_source_lang` and `set_translation`
By default, the command will print `set_source_file` and `set_translation`
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*%s' % expr_re)
expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*%s$' % expr_re)
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
utils.MSG('\ntx set_source_lang -r %(res)s -l %(lang)s %(file)s\n' % {
utils.MSG('\ntx set_source_file -r %(res)s -l %(lang)s %(file)s\n' % {
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
utils.MSG("tx: File does not exist.")
utils.MSG("tx: File ( %s ) does not exist." % os.path.join(path_to_tx, path_to_file))
def _set_source_file(path_to_tx, resource, lang, path_to_file): """Reusable method to set source file.""" # Chdir to the root dir os.chdir(path_to_tx) if not os.path.exists(path_to_file): utils.MSG("tx: File does not exist.") return # instantiate the project.Project prj = project.Project(path_to_tx) root_dir = os.pa...
utils.MSG("tx: File does not exist.")
utils.MSG("tx: File ( %s ) does not exist." % path_to_file)
def cmd_set_translation(argv, path_to_tx): "Assign translation files to a resource" usage="usage: %prog [tx_options] set_translation [options] <file>" description="Assign a file as the translation file of a specific resource"\ " in a given language. These info is stored in a configuration file"\ " and is used for sync...
curpath = '.'
curpath = os.curdir
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
_set_source_file(path_to_tx, resource, source_language, source_file)
_set_source_file(path_to_tx, resource, source_language, os.path.relpath(source_file, path_to_tx))
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
'file': source_file})
'file': os.path.relpath(source_file, curpath)})
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
_set_translation(path_to_tx, resource, lang, f_path)
_set_translation(path_to_tx, resource, lang, os.path.relpath(f_path, path_to_tx))
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
'file': f_path})
'file': os.path.relpath(f_path, curpath)})
def cmd_auto_find(argv, path_to_tx): "Automatically identify translation files." """ This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sh...
self.do_url_request('push_source', multipart=True, files=[( "%s_%s" % (resource['resource_name'],
r = self.do_url_request('push_file', multipart=True, files=[( "%s_%s" % (resource['resource_name'],
def push(self, force=False): """ Push all the resources """
project=self.get_project_slug())
method="POST", project=self.get_project_slug()) r = parse_json(r) uuid = r['files'][0]['uuid'] self.do_url_request('extract_source', data=compile_json({"uuid":uuid}), encoding='application/json', method="POST", project=self.get_project_slug())
def push(self, force=False): """ Push all the resources """
self.do_url_request('push_source', multipart=True,
r = self.do_url_request('push_file', multipart=True,
def push(self, force=False): """ Push all the resources """
project=self.get_project_slug()) def do_url_request(self, api_call, multipart=False, data=None, files=[], **kwargs):
method="POST", project=self.get_project_slug()) r = parse_json(r) uuid = r['files'][0]['uuid'] self.do_url_request('extract_translation', data=compile_json({"uuid":uuid}), encoding='application/json', method="PUT", project=self.get_project_slug(), resource=resource['resource_name'], language=lang) def do_url_request...
def push(self, force=False): """ Push all the resources """
for f in files: file_params.append(MultipartParam.from_file(f[0], f[1])) data, headers = multipart_encode(file_params) req = urllib2.Request(url=url, data=data, headers=headers)
form = MultiPartForm() for info,filename in files: fp = open(filename) form.addField('resource', info.split('_')[0]) form.addField('language', info.split('_')[1]) form.addFile(info, filename, fp) body = str(form) req = RequestWithMethod(url=url, method=method) req.add_header('Content-type', form.getContentType()) re...
def do_url_request(self, api_call, multipart=False, data=None, files=[], **kwargs): """ Issues a url request. """ # Read the credentials from the config file (.transifexrc) home = os.getenv('USERPROFILE') or os.getenv('HOME') txrc = os.path.join(home, ".transifexrc") config = ConfigParser.RawConfigParser()
req = urllib2.Request(url=url, data=data)
req = RequestWithMethod(url=url, data=data, method=method) if encoding: req.add_header("Content-Type",encoding)
def do_url_request(self, api_call, multipart=False, data=None, files=[], **kwargs): """ Issues a url request. """ # Read the credentials from the config file (.transifexrc) home = os.getenv('USERPROFILE') or os.getenv('HOME') txrc = os.path.join(home, ".transifexrc") config = ConfigParser.RawConfigParser()
resources = [ r['slug'] for r in proj_info['resources'] ]
resources = [ '.'.join([vars['project'], r['slug']]) for r in proj_info['resources'] ]
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
resources = [ r['slug'] for r in rel_info['resources'] ]
resources = [ '.'.join([r['project_slug'], r['slug']]) for r in rel_info['resources'] ]
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
resources = [vars['resource']]
resources = [ '.'.join([vars['project'], vars['resource']]) ]
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
proj, res = resource.split('.')
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
vars['project'], resource)
proj, res)
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
resource='.'.join([vars['project'], resource]),
resource=resource,
def _auto_remote(path_to_tx, url): """ Initialize a remote release/project/resource to the current directory. """ utils.MSG("Auto configuring local project from remote URL...") type, vars = utils.parse_tx_url(url) prj = project.Project(path_to_tx) username, password = prj.getset_host_credentials(vars['hostname']) i...
raise Exeption("tx: File ( %s ) does not exist." %
raise Exception("tx: File ( %s ) does not exist." %
def _set_source_file(path_to_tx, resource, lang, path_to_file): """Reusable method to set source file.""" proj, res = resource.split('.') if not proj or not res: raise Exception("\"%s.%s\" is not a valid resource identifier. It should" " be in the following format project_slug.resource_slug." % (proj, res)) if not la...
MSG("Following resources are not available on remote machine:", ", ".join([i['resource_slug'] for i in local_resources]))
MSG("Following resources are not available on remote machine: %s" % ", ".join([ i['resource_slug'] for i in local_resources ]))
def push(self, force=False, resources=[], languages=[]): """ Push all the resources """ raw = self.do_url_request('get_resources', project=self.get_project_slug())
files=[( "%s_%s" % (resource['resource_slug'],
files=[( "%s__%s" % (resource['resource_slug'],
def push(self, force=False): """ Push all the resources """ raw = self.do_url_request('get_resources', project=self.get_project_slug())
form.addField('resource', info.split('_')[0]) form.addField('language', info.split('_')[1])
form.addField('resource', info.split('__')[0]) form.addField('language', info.split('__')[1])
def do_url_request(self, api_call, multipart=False, data=None, files=[], encoding=None, method="GET", **kwargs): """ Issues a url request. """ # Read the credentials from the config file (.transifexrc) home = os.getenv('USERPROFILE') or os.getenv('HOME') txrc = os.path.join(home, ".transifexrc") config = ConfigParser.R...
for lang, f_obj in resource['translations'].iteritems(): print "Pushing %s to %s" % (lang, f_obj['file']) self.do_url_request('push_source', multipart=True, files=[( "%s_%s" % (resource['resource_name'], lang), self.get_full_path(f_obj['file']))], project=self.get_project_slug())
def push(self, force=False): """ Push all the resources """
opener.add_handler(auth_handler)
def do_url_request(self, api_call, multipart=False, data=None, files=[], **kwargs): """ Issues a url request. """ # Read the credentials from the config file (.transifexrc) home = os.getenv('USERPROFILE') or os.getenv('HOME') txrc = os.path.join(home, ".transifexrc") config = ConfigParser.RawConfigParser()
global _debug _debug = 1
DEBUG = True
def main(argv): """ Here we parse the flags (short, long) and we instantiate the classes. """ path_to_tx = None extra_opts = [] try: opts, args = getopt.getopt(argv, "vhd", ["version", "help", "debug", "path_to_tx="]) except getopt.GetoptError: usage() sys.exit(2) for opt, arg in opts: if opt in ("-v", "--version"): pr...
if _debug == 1:
if DEBUG:
def main(argv): """ Here we parse the flags (short, long) and we instantiate the classes. """ path_to_tx = None extra_opts = [] try: opts, args = getopt.getopt(argv, "vhd", ["version", "help", "debug", "path_to_tx="]) except getopt.GetoptError: usage() sys.exit(2) for opt, arg in opts: if opt in ("-v", "--version"): pr...
" --local -r %s \"expression\"' to do the initial configuration." % resource)
"-local -r %s \"expression\"' to do the initial configuration." % resource)
def _auto_local(path_to_tx, resource, source_language, expression, execute=False, source_file=None, nosource=False, regex=False): """ Auto configure local project """ expr_re = '.*%s.*' % expression if not regex: # Force expr to be a valid regex expr (escaped) but keep <lang> intact expr_re = re.escape(expression) exp...
Automatically identify translation files."
def cmd_auto_find(argv, path_to_tx): """ Automatically identify translation files." This command goes through all files in this directory and its subdirectories and tries to find matches to the expression given. The expression should contain '<lang>' to identify the language, or, if the --regex option is defined, sho...
perc = "not yet pulled"
perc = "sync needed"
def cmd_status(argv, path_to_tx): "Print status of current project" usage="usage: %prog [tx_options] status [options]" description="Prints the status of the current project by reading the"\ " data in the configuration file." parser = OptionParser(usage=usage,description=description) parser.add_option("-r","--resource"...
expr_re = re.sub(r"<lang>", '(?P<lang>[^/]+)', '.*%s$' % expr_re)
expr_re = re.sub(r"%s?<lang>" % os.sep, '%(sep)s(?P<lang>[^%(sep)s]+)' % { 'sep': os.sep}, '.*%s$' % expr_re)
def _auto_local(path_to_tx, resource, source_language, expression, execute=False, source_file=None, nosource=False, regex=False): """ Auto configure local project """ expr_re = '.*%s.*' % expression if not regex: # Force expr to be a valid regex expr (escaped) but keep <lang> intact expr_re = re.escape(expression) exp...
utils.MSG("Done.")
def _auto_local(path_to_tx, resource, source_language, expression, execute=False, source_file=None, nosource=False, regex=False): """ Auto configure local project """ expr_re = '.*%s.*' % expression if not regex: # Force expr to be a valid regex expr (escaped) but keep <lang> intact expr_re = re.escape(expression) exp...
path = path_to_tx or utils.find_dot_tx(path_to_tx)
path = utils.find_dot_tx(path_to_tx)
def cmd_init(argv, path_to_tx=None): "Initialize a new transifex project." # Current working dir path root = path_to_tx or os.getcwd() usage="usage: %prog [tx_options] init" description="This command initializes a new project for use with"\ " transifex. It is recommended to execute this command in the"\ " top level di...
print resource, lang
def cmd_set_translation(argv, path_to_tx=None): "Assign translation files to a resource" usage="usage: %prog [tx_options] set_translation [options] <file>" description="Assign a file as the translation file of a specific resource"\ " in a given language. These info is stored in a configuration file"\ " and is used for...
idx = choices.index(choice) voter.votes.insert(idx, vote)
voter.votes.sort(lambda x, y : cmp(choices.index(x.choice), choices.index(y.choice)))
def newVote(request, choices): "Create new votes" if not request.POST['author_name']: return author = PollUser(name=request.POST['author_name']) author.save() voter = Voter(user=author, poll=poll) voter.save() selected_choices = []
print slides
def move(self, queue, slides): queue = queue[6:] # remove 'queue_'-prefix slides = [x[6:] for x in slides.split(',')] # remove 'slide_'-prefix c = cherrypy.thread_data.db.cursor() # prepare slides slides = [dict(queue=queue, id=id, order=n) for (n,id) in enumerate(slides)] print slides c.executemany(""" UPDATE slide ...
print 'updated:', params
def edit(self, id, **kwargs): s = slide.from_id(cherrypy.thread_data.db.cursor(), id) # @todo using private variable! params = s._data.copy() params.update(kwargs) print 'updated:', params return template.render(id=id, preview=params)
print settings
def config(self, action=None, **kwargs): settings = Settings() print settings if action == 'save': error = False with settings: # hack for environmental variables env = {} if 'Env' in kwargs: try: env = kwargs['Env'].split("\r\n") env = filter(lambda x: len(x) > 0, env) env = map(lambda x: tuple(x.split('=')), env) en...
print cherrypy.config print application.config
def index(self): raise cherrypy.InternalRedirect('/slides/list')
print 'submit:', submit
def submit(self, assembler, submit, **kwargs): print 'submit:', submit if submit == 'preview': raise cherrypy.HTTPRedirect('/slides/upload?' + urllib.urlencode(kwargs)) try: s = slide.create(cherrypy.thread_data.db.cursor(), assembler, kwargs) daemon.ipc.Reload() cherrypy.thread_data.db.commit() except: cherrypy.threa...
def __determine_bpi(self, data, frames): if self.version < (2,4,0): return int
def __determine_bpi(self, data, frames, EMPTY="\x00" * 10): if self.version < (2, 4, 0): return int
def __determine_bpi(self, data, frames): if self.version < (2,4,0): return int # have to special case whether to use bitpaddedints here # spec says to use them, but iTunes has it wrong
while o < len(data)-10: name, size, flags = unpack('>4sLH', data[o:o+10])
while o < len(data) - 10: part = data[o:o + 10] if part == EMPTY: bpioff = -((len(data) - o) % 10) break name, size, flags = unpack('>4sLH', part)
def __determine_bpi(self, data, frames): if self.version < (2,4,0): return int # have to special case whether to use bitpaddedints here # spec says to use them, but iTunes has it wrong
o += 10+size if name in frames: asbpi += 1 bpioff = o - len(data)
o += 10 + size if name in frames: asbpi += 1 else: bpioff = o - len(data)
def __determine_bpi(self, data, frames): if self.version < (2,4,0): return int # have to special case whether to use bitpaddedints here # spec says to use them, but iTunes has it wrong
while o < len(data)-10: name, size, flags = unpack('>4sLH', data[o:o+10]) o += 10+size if name in frames: asint += 1 intoff = o - len(data)
while o < len(data) - 10: part = data[o:o + 10] if part == EMPTY: intoff = -((len(data) - o) % 10) break name, size, flags = unpack('>4sLH', part) o += 10 + size if name in frames: asint += 1 else: intoff = o - len(data)
def __determine_bpi(self, data, frames): if self.version < (2,4,0): return int # have to special case whether to use bitpaddedints here # spec says to use them, but iTunes has it wrong
'\xa9grn': 'genre',
'\xa9gen': 'genre',
def pprint(self): """Print tag key=value pairs.""" strings = [] for key in sorted(self.keys()): values = self[key] for value in values: strings.append("%s=%s" % (key, value)) return "\n".join(strings)
remain = line[len(snip):].lstrip()
remain = line[len(snip):].strip()
def _parse_first(self, line): """ Parses the first line of the snippet definition. Returns the snippet type, trigger, description, and options in a tuple in that order. """ cdescr = "" coptions = "" cs = ""
if not isinstance(self.snippets[0],tuple):
if len(self.snippets) and not isinstance(self.snippets[0],tuple):
def setUp(self): self.send(ESC)
help="Stop after defining the snippet. This allows the user" \ "to interactively test the snippet in vim. You must give exactly" \ "one test case on the cmdline. The test will always fail."
help="Stop after defining the snippet. This allows the user " \ "to interactively test the snippet in vim. You must give " \ "exactly one test case on the cmdline. The test will always fail."
def parse_args(): p = optparse.OptionParser("%prog [OPTIONS] <test case names to run>")
@property def rv(self):
def rv():
def ft(self): """ The filetype. """ return self.opt("&filetype", "")
return self._rv @rv.setter def rv(self, value): self._changed = True self._rv = value
def fget(self): return self._rv def fset(self, value): self._changed = True self._rv = value return locals() rv = property(**rv())
def rv(self): """ The return value. This is a list of lines to insert at the location of the placeholder.
self._vstate.update()
def backspace_while_selected(self): """ This is called when backspace was used while a placeholder was selected. """ # BS was called in select mode
moved = self._span_selected.start.line - \ self._span_selected.end.line
moved = 0 if self._vstate.buf_changed: moved = self._span_selected.start.line - \ self._span_selected.end.line
def _chars_entered(self, chars, del_more_lines = 0): if (self._span_selected is not None): self._ctab.current_text = chars
dlines += self._vstate.moved.line + del_more_lines
if self._vstate.buf_changed: dlines += self._vstate.moved.line dlines += del_more_lines
def _update_vim_buffer(self, del_more_lines = 0): if not len(self._csnippets): return
print self.style.ERROR(e)
print self.style.ERROR(str(e))
def handle(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge']
latest_version = Version.objects.using(database).latest('when')
if is_multi_db(): latest_version = Version.objects.using(database).latest('when') else: latest_version = Version.objects.latest('when')
def evolve(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge'] database = options['database']
transaction.leave_transaction_management(using=database)
if is_multi_db(): transaction.leave_transaction_management(using=database) else: transaction.leave_transaction_management()
def evolve(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge'] database = options['database']
print self.style.ERROR("Can't evolve yet. Need to set an evolution baseline.") sys.exit(1)
raise CommandError("Can't evolve yet. Need to set an evolution baseline.")
def handle(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge']
print self.style.ERROR(str(e)) sys.exit(1)
raise CommandError(str(e))
def handle(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge']
sys.exit(1)
raise CommandError('Your models contain changes that Django Evolution cannot resolve automatically.')
def handle(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge']
print self.style.ERROR('Error applying evolution: %s' % str(ex)) sys.exit(1)
raise CommandError('Error applying evolution: %s' % str(ex))
def handle(self, *app_labels, **options): verbosity = int(options['verbosity']) interactive = options['interactive'] execute = options['execute'] compile_sql = options['compile_sql'] hint = options['hint'] purge = options['purge']
self.prefix = self.getValue("prefix", self.prefix or self.makeDefaultPrefix(self.name)) self.mimetype = self.getValue("mimetype", self.mimetype or "application/x-%s" % self.ident.lower()).lower()
self.prefix = self.getValue("prefix", self.prefix if name == self.name else self.makeDefaultPrefix(self.name)) self.mimetype = self.getValue("mimetype", self.mimetype if ident == self.ident else "application/x-%s" % self.ident.lower()).lower()
def promptValues(self): self.name = self.getValue("name", self.name) self.ident = self.getValue("ident", re.sub(r"[^a-zA-Z\d\-_]", "", self.ident or self.name)) self.prefix = self.getValue("prefix", self.prefix or self.makeDefaultPrefix(self.name)) self.mimetype = self.getValue("mimetype", self.mimetype or "ap...
mimetype = ("MIME type", re.compile(r"^[a-zA-Z]+\/[a-zA-Z\-]+$"), "Please use alphabetic characters and dashes in the format: application/x-firebreath"),
mimetype = ("MIME type", re.compile(r"^[a-zA-Z0-9]+\/[a-zA-Z0-9\-]+$"), "Please use alphanumeric characters and dashes in the format: application/x-firebreath"),
def __init__(self, **kwargs): for k, v in kwargs.items(): if hasattr(self, k): setattr(self, k, v) self.keys = AttrDictSimple( name = ("Name", re.compile(r"^.+$"), "Name must be at least one character, and may not contain carriage returns."), ident = ("Identifier", re.compile(r"^[a-zA-Z][a-zA-Z\d_]{2,}$"), "Iden...
wl("License: Eclipse Public License - Version 1.0")
wl("License: Dual license model; choose one of two:") wl(" Eclipse Public License - Version 1.0")
def wl(s): f.write(ind()+s+endl)
return 0
return None
def get_list_info(userdesc, perms, mlist, front_page=0): members = mlist.getRegularMemberKeys() is_member = userdesc.address in members is_owner = userdesc.address in mlist.owner if (mlist.advertised and perms in ('lists', 'admin')) or is_member or is_owner or (not front_page and perms == 'admin'): is_pending = F...
details = get_list_info(udesc, perms, mlist, (email is None and vhost == PLATAL_DOMAIN))[0] result.append(details)
details = get_list_info(udesc, perms, mlist, (email is None and vhost == PLATAL_DOMAIN)) if details is not None: result.append(details[0])
def get_lists(userdesc, perms, vhost, email=None): """ List available lists for the given vhost """ if email is None: udesc = userdesc else: udesc = UserDesc(email.lower(), email.lower(), None, 0) prefix = vhost.lower()+VHOST_SEP names = Utils.list_names() names.sort() result = [] for name in names: if not name.startsw...
mlist._UpdateRecords() mlist.Save()
try: mlist._UpdateRecords() mlist.Save() finally: mlist.Unlock()
def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, inslevel, owners, members): """ Create a new list. @root """ name = vhost.lower() + VHOST_SEP + listname.lower(); if Utils.list_exists(name): return 0 owner = [] for o in owners: email = to_forlife(o)[0] if email is not None: owner.append(ema...
new_params = list(params)
def _dispatch(self, method, params): new_params = list(params) return list_call_dispatcher(self._get_function(method), self.data[0], self.data[1], self.data[2], *params)
return 0
return None
def get_list_info(userdesc, perms, mlist, front_page=0): members = mlist.getRegularMemberKeys() is_member = userdesc.address in members is_owner = userdesc.address in mlist.owner if (mlist.advertised and perms in ('lists', 'admin')) or is_member or is_owner or (not front_page and perms == 'admin'): is_pending = F...
details, members = get_list_info(userdesc, perms, mlist)
infos = get_list_info(userdesc, perms, mlist) if infos is None: return None details, members = infos
def get_members(userdesc, perms, mlist): """ List the members of a list. @mlist """ details, members = get_list_info(userdesc, perms, mlist) members.sort() members = map(lambda member: (get_name(member), member), members) return (details, members, mlist.owner)
return self.get_eff_dist() * (2.**(-1./5) * ref_mass / self.mchirp)**(5./6)
return self.get_eff_dist(instrument) * (2.**(-1./5) * ref_mass / self.mchirp)**(5./6)
def get_chirp_dist(self,instrument,ref_mass = 1.40): return self.get_eff_dist() * (2.**(-1./5) * ref_mass / self.mchirp)**(5./6)
if ' ' in self.__options[c] and '$(macro' not in self.__options[c]: self.__options[c] = ''.join([ "'", self.__options[c], "'" ])
def write_sub_file(self): """ Write a submit file for this Condor job. """ if not self.__log_file: raise CondorSubmitError, "Log file not specified." if not self.__err_file: raise CondorSubmitError, "Error file not specified." if not self.__out_file: raise CondorSubmitError, "Output file not specified."
if ' ' in self.__short_options[c] and '$(macro' not in self.__short_options[c]: self.__short_options[c] = ''.join([ "'", self.__short_options[c], "'" ])
def write_sub_file(self): """ Write a submit file for this Condor job. """ if not self.__log_file: raise CondorSubmitError, "Log file not specified." if not self.__err_file: raise CondorSubmitError, "Error file not specified." if not self.__out_file: raise CondorSubmitError, "Output file not specified."
raise RuntimeError, "failed to lock %s: %s" % (pidfile_path, e)
raise RuntimeError, "failed to lock %s: %s" % (lockfile, e)
def get_lock(lockfile): """ Tries to write a lockfile containing the current pid. Excepts if the lockfile already contains the pid of a running process. Although this should prevent a lock from being granted twice, it can theoretically deny a lock unjustly in the unlikely event that the original process is gone but a...
if '||' in line: tab.append(line.split('||'))
if '||' in line: tab.append(line.split('||')[1:])
def wiki_table_parse(file): #FIXME assumes table files of the form # === title === # ||data||data|| # ||data||data|| tabs = [] titles = [] tab = [] for line in open(file).readlines(): if '===' in line: titles.append(line.replace("=","")) if tab: tabs.append(tab) tab = [] if '||' in line: tab.append(line.split('||')) t...
self.tr
self.add('<tr>')
def __init__(self, two_d_data, title="", caption="", tag="table", num="1"): markup.page.__init__(self, mode="strict_html") self.add("<br>") if title: self.b("%s. %s" %(num, title.upper()) ) self.table() for row in two_d_data: self.tr tdstr = "" for col in row: tdstr += "<td>%s</td>" % (str(col),) self.add(tdstr) self....
self.tr.close()
self.add('</tr>')
def __init__(self, two_d_data, title="", caption="", tag="table", num="1"): markup.page.__init__(self, mode="strict_html") self.add("<br>") if title: self.b("%s. %s" %(num, title.upper()) ) self.table() for row in two_d_data: self.tr tdstr = "" for col in row: tdstr += "<td>%s</td>" % (str(col),) self.add(tdstr) self....
f = os.path.basename(f)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
xml = '<filename file="%s" />' % os.path.basename(f)
xml = '<filename file="%s" />' % f
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
signal during the operation
signal during the operation. Example: >>> try: ... put_connection_filename(filename, working_filename, verbose = True) ... except IOTrappedSignal, e: ... os.kill(os.getpid(), e.signum) ... This example re-transmits the most-recently received signal back to itself following completion of the function call, if a signa...
def set_temp_store_directory(connection, temp_store_directory, verbose = False): """ Sets the temp_store_directory parameter in sqlite. """ if verbose: print >>sys.stderr, "setting the temp_store_directory to %s ..." % temp_store_directory, cursor = connection.cursor() cursor.execute("PRAGMA temp_store_directory = '%s'...
file(working_filename, "w")
file(working_filename, "w").close()
def newsigterm(signum, frame): global __llwapp_write_filename_got_sig __llwapp_write_filename_got_sig.append(signum)
def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None):
def load_fileobj(fileobj, gz = None, xmldoc = None, contenthandler = None):
def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file object fileobj, and return the contents as a LIGO Light Weight document tree. The file object does not need to be seekable. The file is gzip decompressed while reading if gz is set to True. If the optional...
does not need to be seekable. The file is gzip decompressed while reading if gz is set to True. If the optional xmldoc argument is provided and not None, the parsed XML tree will be appended to that document, otherwise a new document will be created. The return value is a tuple, the first element of the tuple is the...
does not need to be seekable. If the gz parameter is None (the default) then gzip compressed data will be automatically detected and decompressed, otherwise decompression can be forced on or off by setting gz to True or False respectively. If the optional xmldoc argument is provided and not None, the parsed XML tree ...
def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file object fileobj, and return the contents as a LIGO Light Weight document tree. The file object does not need to be seekable. The file is gzip decompressed while reading if gz is set to True. If the optional...
>>> xmldoc, digest = utils.load_fileobj(sys.stdin, verbose = True, gz = True)
>>> xmldoc, digest = utils.load_fileobj(sys.stdin)
def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file object fileobj, and return the contents as a LIGO Light Weight document tree. The file object does not need to be seekable. The file is gzip decompressed while reading if gz is set to True. If the optional...
if gz: fileobj = gzip.GzipFile(mode = "rb", fileobj = RewindableInputFile(fileobj))
if gz != False: fileobj = RewindableInputFile(fileobj) magic = fileobj.read(2) fileobj.seek(0, os.SEEK_SET) if gz == True or magic == '\037\213': fileobj = gzip.GzipFile(mode = "rb", fileobj = fileobj)
def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file object fileobj, and return the contents as a LIGO Light Weight document tree. The file object does not need to be seekable. The file is gzip decompressed while reading if gz is set to True. If the optional...
def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None):
def load_filename(filename, verbose = False, gz = None, xmldoc = None, contenthandler = None):
def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file identified by filename, and return the contents as a LIGO Light Weight document tree. Helpful verbosity messages are printed to stderr if verbose is True, and the file is gzip decompressed...
verbosity messages are printed to stderr if verbose is True, and the file is gzip decompressed while reading if gz is set to True. If filename is None, then stdin is parsed. If the optional xmldoc argument is provided and not None, the parsed XML tree will be appended to that document, otherwise a new document will be...
verbosity messages are printed to stderr if verbose is True. All other parameters are passed verbatim to load_fileobj(), see that function for more information.
def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file identified by filename, and return the contents as a LIGO Light Weight document tree. Helpful verbosity messages are printed to stderr if verbose is True, and the file is gzip decompressed...
>>> xmldoc = utils.load_filename(name, verbose = True, gz = (name or "stdin").endswidth(".gz"))
>>> xmldoc = utils.load_filename(name, verbose = True)
def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file identified by filename, and return the contents as a LIGO Light Weight document tree. Helpful verbosity messages are printed to stderr if verbose is True, and the file is gzip decompressed...
fileobj = file(filename)
fileobj = open(filename, "rb")
def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file identified by filename, and return the contents as a LIGO Light Weight document tree. Helpful verbosity messages are printed to stderr if verbose is True, and the file is gzip decompressed...
def load_url(url, verbose = False, gz = False, xmldoc = None, contenthandler = None):
def load_url(url, verbose = False, gz = None, xmldoc = None, contenthandler = None):
def load_url(url, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ This function has the same behaviour as load_filename() but accepts a URL instead of a filename. Any source from which Python's urllib2 library can read data is acceptable. stdin is parsed if the URL is None. If the optional xm...
the URL is None. If the optional xmldoc argument is provided and is not None, the parsed XML tree will be appended to that document, otherwise a new document will be created.
the URL is None.
def load_url(url, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ This function has the same behaviour as load_filename() but accepts a URL instead of a filename. Any source from which Python's urllib2 library can read data is acceptable. stdin is parsed if the URL is None. If the optional xm...
xml = '<filename file="%s" />' % f
xml = '<filename file="%s" />' % os.path.basename(f)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
template = """ <profile namespace="condor" key="universe">%s</profile>\n""" xml = xml + template % (node.job().get_universe())
if node.get_dax_collapse(): template = """ <profile namespace="condor" key="universe">vanilla</profile>\n""" xml = xml + template else: template = """ <profile namespace="condor" key="universe">%s</profile>\n""" xml = xml + template % (node.job().get_universe())
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
def New(Type, columns = None):
def New(Type, columns = None, **kwargs):
def New(Type, columns = None): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a tab...
new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}))
new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}), **kwargs)
def New(Type, columns = None): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a tab...