rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
n = nextrev
def accumulate(text): n = nextrev # track which files are added in which changeset and the # corresponding _local_ changeset revision files = self.changelog.extract(text)[3] for f in files: changed.setdefault(f, []).append(n) n += 1
changed.setdefault(f, []).append(n) n += 1
changed.setdefault(f, []).append(nextrev[0]) nextrev[0] += 1
def accumulate(text): n = nextrev # track which files are added in which changeset and the # corresponding _local_ changeset revision files = self.changelog.extract(text)[3] for f in files: changed.setdefault(f, []).append(n) n += 1
nmode = gitmode(util.is_exec(repo.wjoin(f), mmap.execf(f)))
if node2: nmode = gitmode(mmap2.execf(f)) else: nmode = gitmode(util.is_exec(repo.wjoin(f), mmap.execf(f)))
def addmodehdr(header, omode, nmode): if omode != nmode: header.append('old mode %s\n' % omode) header.append('new mode %s\n' % nmode)
raise hg.RepoError(_("couldn't parse location %s") % path)
self.repoerror(_("couldn't parse location %s") % path)
def __init__(self, ui, path, create=0): self._url = path self.ui = ui
raise hg.RepoError(_("could not create remote repo"))
self.repoerror(_("could not create remote repo"))
def __init__(self, ui, path, create=0): self._url = path self.ui = ui
raise hg.RepoError(_("no suitable response from remote hg"))
self.repoerror(_("no suitable response from remote hg"))
def validate_repo(self, ui, sshcmd, args, remotecmd): # cleanup up previous run self.cleanup()
raise hg.RepoError(_("unexpected response '%s'") % l)
self.repoerror(_("unexpected response '%s'") % l)
def call(self, cmd, **args): r = self.do_cmd(cmd, **args) l = r.readline() self.readerr() try: l = int(l) except: raise hg.RepoError(_("unexpected response '%s'") % l) return r.read(l)
raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def heads(self): d = self.call("heads") try: return map(bin, d[:-1].split(" ")) except: raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def branches(self, nodes): n = " ".join(map(hex, nodes)) d = self.call("branches", nodes=n) try: br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] return br except: raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def between(self, pairs): n = "\n".join(["-".join(map(hex, p)) for p in pairs]) d = self.call("between", pairs=n) try: p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] return p except: raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
raise hg.RepoError(_("push refused: %s") % d)
self.repoerror(_("push refused: %s") % d)
def unbundle(self, cg, heads, source): d = self.call("unbundle", heads=' '.join(map(hex, heads))) if d: raise hg.RepoError(_("push refused: %s") % d)
raise hg.RepoError(_("push refused: %s") % d)
self.repoerror(_("push refused: %s") % d)
def addchangegroup(self, cg, source, url): d = self.call("addchangegroup") if d: raise hg.RepoError(_("push refused: %s") % d) while 1: d = cg.read(4096) if not d: break self.pipeo.write(d) self.readerr()
('d', 'date', "", 'data'),
('d', 'date', "", 'date code'),
def verify(ui, repo): """verify the integrity of the repository""" return repo.verify()
('d', 'date', "", 'date'),
('d', 'date', "", 'date code'),
def verify(ui, repo): """verify the integrity of the repository""" return repo.verify()
ui.status("\n")
ui.status("\n\n")
def show_changeset(ui, repo, rev=0, changenode=None, filelog=None): """show a single changeset or file revision""" changelog = repo.changelog if filelog: log = filelog filerev = rev node = filenode = filelog.node(filerev) changerev = filelog.linkrev(filenode) changenode = changenode or changelog.node(changerev) else: l...
for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'): if repo.dirstate.state(abs) == '?':
rev = opts['rev'] if rev: node = repo.lookup(rev) else: node = None for src, abs, rel, exact in walk(repo, pats, opts, node=node, head='(?:.*/|)'): if not node and repo.dirstate.state(abs) == '?':
def locate(ui, repo, *pats, **opts): """locate files matching specific patterns Print all files under Mercurial control whose names match the given patterns. This command searches the current directory and its subdirectories. To search an entire repository, move to the root of the repository. If no patterns are giv...
modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable])
modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
def helpext(name): try: mod = findext(name) except KeyError: raise UnknownCommand(name)
res.append([name, comm]) return res
author = patch_node.getAttribute("author") date = patch_node.getAttribute("date") yield author, date, name, comm
def darcs_changes(darcsRepo): """Gets the changes list from the given darcs repository. This returns the chronological list of changes as (change name, change summary).""" changes = cmd("darcs changes --reverse --xml-output", darcsRepo) doc = xml_dom.parseString(changes) res = [] for patch_node in doc....
def hg_commit( hg_repo, text ): writefile("/tmp/msg", text) cmd("hg add -X _darcs *", hg_repo) cmd("hg commit -l /tmp/msg", hg_repo) os.unlink("/tmp/msg")
def hg_commit( hg_repo, text, author, date ): fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_") writefile(tmpfile, text) cmd("hg add -X _darcs", hg_repo) cmd("hg remove -X _darcs --after", hg_repo) cmd("hg commit -l %s -u '%s' -d '%s 0'" % (tmpfile, author, date), hg_repo) os.unlink(tmpfile)
def hg_commit( hg_repo, text ): writefile("/tmp/msg", text) cmd("hg add -X _darcs *", hg_repo) cmd("hg commit -l /tmp/msg", hg_repo) os.unlink("/tmp/msg")
for summary, description in darcs_changes(darcs_repo):
for author, date, summary, description in darcs_changes(darcs_repo):
def hg_commit( hg_repo, text ): writefile("/tmp/msg", text) cmd("hg add -X _darcs *", hg_repo) cmd("hg commit -l /tmp/msg", hg_repo) os.unlink("/tmp/msg")
hg_commit(hg_repo, text)
epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S'))) hg_commit(hg_repo, text, author, epoch)
def hg_commit( hg_repo, text ): writefile("/tmp/msg", text) cmd("hg add -X _darcs *", hg_repo) cmd("hg commit -l /tmp/msg", hg_repo) os.unlink("/tmp/msg")
accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in "\t\n\r ": accept.append(line.strip()) else: accept = accept + line[7:].split(',') env['HTTP_ACCEPT'] = ','.join(accept)
for header in [h for h in self.headers.keys() \ if h not in ('content-type', 'content-length')]: hkey = 'HTTP_' + header.replace('-', '_').upper() hval = self.headers.getheader(header) hval = hval.replace('\n', '').strip() if hval: env[hkey] = hval env['SERVER_PROTOCOL'] = self.request_version
def do_hgweb(self): path_info, query = _splitURI(self.path)
def dodiff(ui, repo, diffcmd, pats, opts):
def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
def dodiff(ui, repo, diffcmd, pats, opts): def snapshot_node(files, node): '''snapshot files as of some revision''' changes = repo.changelog.read(node) mf = repo.manifest.read(changes[0]) dirname = '%s.%s' % (os.path.basename(repo.root), short(node)) base = os.path.join(tmproot, dirname) os.mkdir(base) if not ui.quiet:...
util.system('%s %s %s %s' % (util.shellquote(diffcmd), ' '.join(opts['option']), util.shellquote(dir1), util.shellquote(dir2)), cwd=tmproot)
cmdline = ('%s %s %s %s' % (util.shellquote(diffcmd), ' '.join(map(util.shellquote, diffopts)), util.shellquote(dir1), util.shellquote(dir2))) ui.debug('running %r in %s\n' % (cmdline, tmproot)) util.system(cmdline, cwd=tmproot)
def snapshot_wdir(files): '''snapshot files from working directory. if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files.''' dirname = os.path.basename(repo.root) base = os.path.join(tmproot, dirname) os.mkdir(base) if not ui.quiet: ui.write_err(_('making s...
an external program. The default program used is "diff -Npru".
an external program. The default program used is diff, with default options "-Npru".
def extdiff(ui, repo, *pats, **opts): '''use external program to diff repository (or selected files) Show differences between revisions for the specified files, using an external program. The default program used is "diff -Npru". To select a different program, use the -p option. The program will be passed the names ...
return dodiff(ui, repo, opts['program'] or 'diff -Npru', pats, opts)
return dodiff(ui, repo, opts['program'] or 'diff', opts['option'] or ['-Npru'], pats, opts)
def extdiff(ui, repo, *pats, **opts): '''use external program to diff repository (or selected files) Show differences between revisions for the specified files, using an external program. The default program used is "diff -Npru". To select a different program, use the -p option. The program will be passed the names ...
return dodiff(ui, repo, path, pats, opts) mydiff.__doc__ = '''use %s to diff repository (or selected files)
return dodiff(ui, repo, path, diffopts, pats, opts) mydiff.__doc__ = '''use %(path)r to diff repository (or selected files)
def mydiff(ui, repo, *pats, **opts): return dodiff(ui, repo, path, pats, opts)
files, using the %s program.
files, using the %(path)r program.
def mydiff(ui, repo, *pats, **opts): return dodiff(ui, repo, path, pats, opts)
working directory files are compared to its parent.''' % (cmd, cmd)
working directory files are compared to its parent.''' % { 'path': path, }
def mydiff(ui, repo, *pats, **opts): return dodiff(ui, repo, path, pats, opts)
coro = self.__loop.create_server(self.__factory, ipaddr, parsed.port)
coro = self.__loop.create_server(self.__factory, "0.0.0.0", parsed.port)
def run(self): asyncio.set_event_loop(self.__loop)
arduinoInterface = arduinoInterface(arduinoCallbacks)
arduinoInterface = ArduinoInterface(arduinoCallbacks)
def onDriveMotor(args): print("On DriveMotor") uiServer.announceLeftMotorSpeed(args[0]) uiServer.announceRightMotorSpeed(args[1])
core_state["base_path"] = os.path.dirname (starting_filename)
base_path = core_state["base_path"] = os.path.dirname (starting_filename)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
real_filename = os.path.join (core_state["base_path"], rel_name)
real_filename = os.path.join (base_path, rel_name)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
real_filename = os.path.join (core_state["base_path"], filename)
real_filename = os.path.join (base_path, filename)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
real_filename = os.path.join (core_state["base_path"], rel_name) if os.path.isfile (real_filename):
attempted_path = os.path.join (curr_base_path, rel_name) sys.stderr.write ("\nAttempted path: |" + attempted_path + "|") ret_filename = safePath (attempted_path, base_path) if None == ret_filename: noteAttemptedEscape (bottom, rel_name, core_state["x"]) displayLinkInfo (bottom, core_state) elif os.path.isfile (ret_fil...
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
filename = rel_name
filename = unBasePath (ret_filename, base_path)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
noteMissingPage (bottom, rel_name, core_state["x"])
noteMissingPage (bottom, ret_filename, core_state["x"])
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
filename = "Start.hylt"
filename = "./Start.hylt"
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
opt_value = config_parser.getint (sect, opt)
opt_value = fetch_function (sect, opt)
def generateConfiguration (base_path): """Generate a configuration for a given instance of Hylt. There are multiple config file locations that we need to read from, and various default values that must be set if not present in the config files. """ config_file_list = [ SITE_CONFIG_FILE, os.path.expanduser ("~/.hylt.c...
if None != os.getenv ("EDITOR", None):
if (config["collection"]["editable"] and None != os.getenv ("EDITOR", None)):
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
core_state["title"] = generateTitle (starting_filename)
core_state["title"] = generateTitle (filename)
def hyltMain (meta_screen, starting_filename): curses.curs_set(0)
link_text += char
link_filename += char
def readHyltFile (filename, core_state): """Given a particular filename, this function parses it and returns the collection of values (in core_state) necessary for properly handling the display and navigation of the page. The parser is a finite state machine. The FSM is actually line-based, and resets at the end of e...
sys.stderr.write ("\n|" + base_path + "| + |" + path + "| = |" + attempted_path + "|")
def safePath (path, base_path): """Check the attempted path to make sure that it doesn't attempt to escape the 'sandbox' created by the start page definition. Note that things like ../ are perfectly valid in links; they just can't take the program out of the root path. If it tries to, return None; otherwise, return t...
sys.stderr.write ("Loading |" + filename + "|")
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
sys.stderr.write ("\nAttempted path: |" + attempted_path + "|")
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
sys.stderr.write(page + "\n")
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
elif ord ('e') == keypress: if config["collection"]["editable"]: invokeEditor (editor, filename) curses.reset_prog_mode () curses.curs_set(1) curses.curs_set(0) fresh_page = True curr_loc_info = None elif ord ('d') == keypress: if os.path.isfile (config["pyui"]["documentation_root"]): current_directory = os.getcwd ()...
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
elif ord ('e') == keypress: if config["collection"]["editable"]: invokeEditor (editor, filename) curses.reset_prog_mode () curses.curs_set(1) curses.curs_set(0) fresh_page = True curr_loc_info = None elif ord ('d') == keypress: if os.path.isfile (config["pyui"]["documentation_root"]): current_directory = os.getcwd ()...
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
def historyAdd (core_state, filename = None):
def historyAdd (core_state, filename):
def historyAdd (core_state, filename = None): """Add a page to the history. If there's a filename, it's assumed to be from some external source (a search result), and as such has no default knowledge of locations on the page, etc. If there is no filename, it's a snapshot of the current page, and saves that data. """ ...
if filename: filename = core_state["history"][core_state["history_position"]]["filename"] history_dict = { "filename": filename, "cx": core_state["cx"], "cy": core_state["cy"], "selected_link": core_state["selected_link"] } history_position = core_state["history_position"] new_history = core_state["history"][...
history_dict = { "filename": filename, "cx": 0, "cy": 0, "selected_link": 0 } core_state["history"].append (history_dict)
def historyAdd (core_state, filename = None): """Add a page to the history. If there's a filename, it's assumed to be from some external source (a search result), and as such has no default knowledge of locations on the page, etc. If there is no filename, it's a snapshot of the current page, and saves that data. """ ...
core_state["history_position"] = min(0, max(len(core_state["history"]) - 1, old_pos + step))
core_state["history_position"] = max(0, min(len(core_state["history"]) - 1, old_pos + step))
def historyMove (core_state, step): """ Loads pages from forward (positive step) or backward (negative step) history and returns real number of steps if move was successful, 0 otherwise """ old_pos = core_state["history_position"] core_state["history_position"] = min(0, max(len(core_state["history"]) - 1, old_pos + ste...
path_to_check = os.path.dirname (filename)
path_to_check = os.path.dirname (filename).strip ()
def invokeEditor (editor, filename): """Invoke an editor via spawnlp. """ # We need to make any missing subdirectories in the path. path_to_check = os.path.dirname (filename) should_edit = True if not os.path.exists (path_to_check): try: os.makedirs (os.path.dirname (filename)) except: # Something bad happened; probab...
if not os.path.exists (path_to_check):
if ("" != path_to_check) and (not os.path.exists (path_to_check)):
def invokeEditor (editor, filename): """Invoke an editor via spawnlp. """ # We need to make any missing subdirectories in the path. path_to_check = os.path.dirname (filename) should_edit = True if not os.path.exists (path_to_check): try: os.makedirs (os.path.dirname (filename)) except: # Something bad happened; probab...
"filename": core_state["filename"], "cx": core_state[cx], "cy": core_state[cy],
"filename": filename, "cx": core_state["cx"], "cy": core_state["cy"],
def historyAdd (core_state, filename = None): """Add a page to the history. If there's a filename, it's assumed to be from some external source (a search result), and as such has no default knowledge of locations on the page, etc. If there is no filename, it's a snapshot of the current page, and saves that data. """ ...
def exportToHTML (filename, core_state):
def exportToHTML (filename, data_array, link_list):
def exportToHTML (filename, core_state): """Exports a given filename to an XHTML document. The document is stored in the same location as the original file. """ data_array = core_state["data_array"] link_list = core_state["link_list"] file = open (filename, "w") file.write ("<?xml version=\"1.0\" encoding=\"utf-8\"...
data_array = core_state["data_array"] link_list = core_state["link_list"]
def exportToHTML (filename, core_state): """Exports a given filename to an XHTML document. The document is stored in the same location as the original file. """ data_array = core_state["data_array"] link_list = core_state["link_list"] file = open (filename, "w") file.write ("<?xml version=\"1.0\" encoding=\"utf-8\"...
exportToHTML (filename[:-4] + "html", core_state) displayNote (bottom, "Exported to '" + filename[:-4] + "html' ...", core_state)
exportToHTML (filename[:-4] + "html", core_state["data_array"], core_state["link_list"]) displayNote (bottom, "Exported to '" + filename[:-4] + "html' ...", core_state["x"])
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
core_state["filename"] = os.path.basename (starting_filename)
filename = os.path.basename (starting_filename)
def hyltMain (meta_screen, starting_filename): curses.curs_set(0)
core_state["history"] = [core_state["filename"]]
core_state["history"] = []
def hyltMain (meta_screen, starting_filename): curses.curs_set(0)
core_state["filename"] = core_state["history"][-1]
filename = core_state["history"][-1]
def hyltMain (meta_screen, starting_filename): curses.curs_set(0)
curses.wrapper (hyltMain, config["documentation"]["documentation_root"]) curses.reset_prog_mode () curses.curs_set(1) curses.curs_set(0) main_needs_redraw = True
current_directory = os.getcwd() hyltMain(meta_screen,config["documentation"]["documentation_root"]) os.chdir(current_directory)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
real_config[sect][opt] = opt_dict["default"]
if "environment" == opt_dict["type"]: real_config[sect][opt] = os.getenv (opt_dict["variable"], opt_dict["default"]) else: real_config[sect][opt] = opt_dict["default"]
def generateConfiguration (): """Generate a configuration for a given instance of Hylt. There are multiple config file locations that we need to read from, and various default values that must be set if not present in the config files. """ config_file_list = [ SITE_CONFIG_FILE, os.path.expanduser ("~/.hylt.conf"), "h...
if (config["collection"]["editable"] and None != os.getenv ("EDITOR", None)):
if config["collection"]["editable"]:
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
os.system (os.getenv ("EDITOR") + " \"" + dest + "\"")
invokeEditor (editor, dest)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
if (config["collection"]["editable"] and None != os.getenv ("EDITOR", None)): os.system (os.getenv ("EDITOR") + " \"" + filename + "\"")
if config["collection"]["editable"]: invokeEditor (editor, filename)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
editor = os.getenv("EDITOR", "vi") displayNote(bottom, "File not found. Do you want to create this file using " + os.path.basename(editor) + " ? (y/n) ", core_state["x"] - 1) if (ord('y') == bottom.getch(0, 0)): os.spawnlp(os.P_WAIT, editor, real_path)
displayNote (bottom, "File not found. Do you want to create this file? [y/N] ", core_state["x"] - 1) response = bottom.getch (0, 0) if ord ('y') == response or ord ('Y') == response: invokeEditor (editor, real_path) curses.reset_prog_mode () curses.curs_set(1) curses.curs_set(0)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
print "ERROR: You must pass either no parameters (which uses index.hylt)"
print "ERROR: You must pass either no parameters (which uses Start.hylt)"
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Cha...
len (core_state["history"]) - 1)
len (core_state["history"]) - 1))
def historyMove (core_state, step): """ Load a page from the forward (positive step) or backward (negative step) history; return the real number of steps if the move was successful and 0 otherwise. """ old_pos = core_state["history_position"] core_state["history_position"] = max (0, min (old_pos + step, len (core_stat...
if core_state["history_position"] < 0: return if 0 > core_state["history"][core_state["history_position"]]["cx"]: core_state["history"][core_state["history_position"]]["cx"] = 0 elif core_state["history"][core_state["history_position"]]["cx"] > core_state["mx"] - 1: core_state["history"][core_state["history_position"]...
if core_state["history_position"] >= 0: curr_location = core_state["history"][core_state["history_position"]] if 0 > curr_location["cx"]: curr_location["cx"] = 0 elif curr_location["cx"] > core_state["mx"] - 1: curr_location["cx"] = core_state["mx"] - 1 if 0 > curr_location["cy"]: curr_location["cy"] = 0 elif curr_loca...
def fixCursorCoords (core_state): """Various functions may put the screen cursor out of the possible range. Instead of duplicating the errorchecking everywhere, a single fixCursorCoords before an attempted screen display can fix them up. """ if core_state["history_position"] < 0: return if 0 > core_state["history"][...
file = open (os.path.join (core_state["base_path"], filename), "w")
file = open (filename, "w")
def exportToHTML (filename, core_state): """Exports a given filename to an XHTML document. The document is stored in the same location as the original file. """ data_array = core_state["data_array"] link_list = core_state["link_list"] file = open (os.path.join (core_state["base_path"], filename), "w") file.write ("...
base_path = core_state["base_path"]
def readHyltFile (filename, core_state): """Given a particular filename, this function parses it and returns the collection of values (in core_state) necessary for properly handling the display and navigation of the page. The parser is a finite state machine. The FSM is actually line-based, and resets at the end of e...
file = open (os.path.join (base_path, filename), "r")
file = open (filename, "r")
def readHyltFile (filename, core_state): """Given a particular filename, this function parses it and returns the collection of values (in core_state) necessary for properly handling the display and navigation of the page. The parser is a finite state machine. The FSM is actually line-based, and resets at the end of e...
safe_link = safePath (possible_link, base_path)
safe_link = safePath (possible_link)
def readHyltFile (filename, core_state): """Given a particular filename, this function parses it and returns the collection of values (in core_state) necessary for properly handling the display and navigation of the page. The parser is a finite state machine. The FSM is actually line-based, and resets at the end of e...
def safePath (path, base_path):
def safePath (path):
def safePath (path, base_path): """Check the attempted path to make sure that it doesn't attempt to escape the 'sandbox' created by the start page definition. Note that things like ../ are perfectly valid in links; they just can't take the program out of the root path. If it tries to, return None; otherwise, return t...
attempted_path = os.path.normpath (os.path.join (base_path, path)) if attempted_path.startswith (base_path):
attempted_path = os.path.normpath (path) if not (attempted_path.startswith("..") or attempted_path.startswith("/")):
def safePath (path, base_path): """Check the attempted path to make sure that it doesn't attempt to escape the 'sandbox' created by the start page definition. Note that things like ../ are perfectly valid in links; they just can't take the program out of the root path. If it tries to, return None; otherwise, return t...
def generateConfiguration (base_path):
def generateConfiguration ():
def generateConfiguration (base_path): """Generate a configuration for a given instance of Hylt. There are multiple config file locations that we need to read from, and various default values that must be set if not present in the config files. """ config_file_list = [ SITE_CONFIG_FILE, os.path.expanduser ("~/.hylt.c...
os.path.join (base_path, "hylt.conf")
"hylt.conf"
def generateConfiguration (base_path): """Generate a configuration for a given instance of Hylt. There are multiple config file locations that we need to read from, and various default values that must be set if not present in the config files. """ config_file_list = [ SITE_CONFIG_FILE, os.path.expanduser ("~/.hylt.c...
base_path = core_state["base_path"] = os.path.dirname (starting_filename)
os.chdir (os.path.dirname (starting_filename))
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
core_state["curr_base_path"] = core_state["base_path"]
core_state["curr_base_path"] = ""
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
config = core_state["config"] = generateConfiguration (base_path)
config = core_state["config"] = generateConfiguration ()
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
rel_name = core_state["link_list"][core_state["selected_link"]] real_filename = os.path.join (base_path, rel_name) os.system (os.getenv ("EDITOR") + " \"" + real_filename + "\"")
dest = os.path.join (core_state["curr_base_path"], core_state["link_list"][core_state["selected_link"]]) os.system (os.getenv ("EDITOR") + " \"" + dest + "\"")
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
real_filename = os.path.join (base_path, filename) os.system (os.getenv ("EDITOR") + " \"" + real_filename + "\"")
os.system (os.getenv ("EDITOR") + " \"" + filename + "\"")
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
rel_path = os.path.normpath (os.path.join (
real_path = os.path.normpath (os.path.join (
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
real_path = os.path.join (base_path, rel_path)
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
filename = rel_path
filename = real_path
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
noteMissingPage (bottom, rel_path, core_state["x"],
noteMissingPage (bottom, real_path, core_state["x"],
def hyltMain (meta_screen, starting_filename): """The core Hylt functionality. Contains the main input and display loops, lots of initialization, and so on. """ curses.curs_set(0) # Remember: Parameters are in the order of (y, x). meta_y, meta_x = meta_screen.getmaxyx() core_state = {"y": meta_y, "x": meta_x} # Kee...
self._monitor = kaa.notifier.SocketDispatcher(self.handle_connection)
self._monitor = kaa.notifier.WeakSocketDispatcher(self.handle_connection)
def __init__(self, address, auth_secret = None): self._auth_secret = auth_secret if type(address) in types.StringTypes: if address.find('/') == -1: # create socket in kaa temp dir address = '%s/%s' % (kaa.TEMP, address) if os.path.exists(address): # maybe a server is already running at this address, test it try: s = s...
class IPCChannel:
class IPCChannel(object):
def close(self): for client in self.clients.values(): client.handle_close()
self._rmon = kaa.notifier.SocketDispatcher(self.handle_read)
self._rmon = kaa.notifier.WeakSocketDispatcher(self.handle_read)
def __init__(self, server_or_address, auth_secret = None, sock = None): if not sock: if type(server_or_address) in types.StringTypes: server_or_address = '%s/%s' % (kaa.TEMP, server_or_address) self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) if type(server_or_address) == tuple: self.socket = socket.sock...
self._wmon = kaa.notifier.SocketDispatcher(self.handle_write)
self._wmon = kaa.notifier.WeakSocketDispatcher(self.handle_write)
def __init__(self, server_or_address, auth_secret = None, sock = None): if not sock: if type(server_or_address) in types.StringTypes: server_or_address = '%s/%s' % (kaa.TEMP, server_or_address) self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) if type(server_or_address) == tuple: self.socket = socket.sock...
_debug(1, "<- REQUEST: seq=%d, type=%s, data=%d" % (seq, packet_type, len(pdata)))
_debug(1, "<- REQUEST: seq=%d, type=%s, data=%d, timeout=%d" % (seq, packet_type, len(pdata), timeout))
def _send_packet(self, packet_type, data, seq = 0, timeout = None, reply_cb = None): if not self.socket: return
pass
def __init__(self, server_or_address, auth_secret = None, sock = None): super(IPCClient, self).__init__(server_or_address, auth_secret, sock) kaa.signals["shutdown"].connect_weak(self.handle_close)
def ping(self): start = time.time() if self.request("PING", None): return time.time() - start return False
object.__setattr__(self, attr, value)
return object.__setattr__(self, attr, value)
def __setattr__(self, attr, value): if attr == "_ref": object.__setattr__(self, attr, value) return setattr(self._ref(), attr, value)
if not self._authenticated: if packet_type in ('RESP', 'AUTH'): self._write_buffer = header + payload + self._write_buffer self._handle_write(close_on_error=False) if not self._wmon.active() and self._write_buffer: self._wmon.register(self._socket.fileno(), kaa.notifier.IO_WRITE) return True
if not self._authenticated and packet_type not in ('RESP', 'AUTH'):
def _send_packet(self, seq, packet_type, payload): """ Send a packet (header + payload) to the other side. """ if not self._socket: return header = struct.pack("I4sI", seq, packet_type, len(payload)) if not self._authenticated: if packet_type in ('RESP', 'AUTH'): self._write_buffer = header + payload + self._write_buff...
return True self._write_buffer += header + payload
def _send_packet(self, seq, packet_type, payload): """ Send a packet (header + payload) to the other side. """ if not self._socket: return header = struct.pack("I4sI", seq, packet_type, len(payload)) if not self._authenticated: if packet_type in ('RESP', 'AUTH'): self._write_buffer = header + payload + self._write_buff...
if not self._wmon.active() and self._write_buffer: self._wmon.register(self._socket.fileno(), kaa.notifier.IO_WRITE)
log.info('Sent response to challenge from client.') self._write_buffer += self._write_buffer_delayed self._write_buffer_delayed = '' self._flush()
def _handle_packet_before_auth(self, seq, type, payload): """ This function handles any packet received by the remote end while we are waiting for authentication. It responds to AUTH or RESP packets (auth packets) while closing the connection on all other packets (non- auth packets).
if len(pickled_columns) == 0:
if pickled_columns != None and len(pickled_columns) == 0:
def iter_raw_data((query_info, rows), columns): """ Takes query data (the tuple returned by Database.query_raw()) and returns a generator that iterates over the rows in the result set, where each iteration provides a tuple of attributes corresponding to the tuple of column names in the columns parameter. e.g. for foo,...
else:
elif pickled_columns != None:
def iter_raw_data((query_info, rows), columns): """ Takes query data (the tuple returned by Database.query_raw()) and returns a generator that iterates over the rows in the result set, where each iteration provides a tuple of attributes corresponding to the tuple of column names in the columns parameter. e.g. for foo,...
else:
elif i in __timers:
def step( sleep = True, external = True ): # IDEA: Add parameter to specify max timeamount to spend in mainloop """Do one step forward in the main loop. First all timers are checked for expiration and if necessary the accociated callback function is called. After that the timer list is searched for the next timer that ...
new_prefix = '%s' % (prefix) if not isinstance(self._schema, Var):
new_prefix = prefix if not isinstance(self._schema, Var) and not isinstance(self, List):
def _cfg_string(self, prefix, print_desc=True): """ Convert object into a string to write into a config file. """ ret = [] prefix = prefix + self._name if type(self._schema) == Var and print_desc: ret.append('#\n# %s\n# %s\n#\n' % (prefix, unicode_to_str(self._desc))) print_desc = False