rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
def __init__(self, componentType=Asn1Object, value=[]): | def __init__(self, componentType=Asn1Object, value=None): | def __init__(self, componentType=Asn1Object, value=[]): Sequence.__init__(self) self.componentType = componentType ## Add each item in the list to ourselves, which automatically ## checks each one to ensure it is of the correct type. self.value = [] for item in value: self.append(item) pass return |
for item in value: self.append(item) | if value: for item in value: self.append(item) pass | def __init__(self, componentType=Asn1Object, value=[]): Sequence.__init__(self) self.componentType = componentType ## Add each item in the list to ourselves, which automatically ## checks each one to ensure it is of the correct type. self.value = [] for item in value: self.append(item) pass return |
if config.has_key("flavourdir"): template_files = tools.Walk(self._request, config["flavourdir"], 1, pattern) | flavourdir = config.get("flavourdir", datadir) dirname = data["root_datadir"] if os.path.isfile(dirname): dirname = os.path.dirname(dirname) dirname = dirname[len(datadir):] template_files = None while len(dirname) > 0: template_files = os.listdir(flavourdir + dirname) template_files = [flavourdir + dirname + m f... | def _getFlavour(self, taste='html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ data = self._request.getData() config = self._request.getConfiguration() |
datadir = config["datadir"] dirname = data["root_datadir"] if os.path.isfile(dirname): dirname = os.path.dirname(dirname) template_files = None while len(dirname) >= len(datadir): template_files = tools.Walk(self._request, dirname, 1, pattern) if template_files: break dirname = os.path.split(dirname)[0] | template_files = os.listdir(flavourdir) template_files = [flavourdir + os.sep + m for m in template_files if m.endswith("." + taste)] | def _getFlavour(self, taste='html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ data = self._request.getData() config = self._request.getConfiguration() |
template_files = tools.Walk(self._request, config['datadir'], 1, pattern) | template_files = self._getIncludedFlavour(taste) if not template_files: raise NoSuchFlavourException("Flavour '" + taste + "' does not exist.") | def _getFlavour(self, taste='html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ data = self._request.getData() config = self._request.getConfiguration() |
flavour.update(DEFAULT_FLAVOURS.get(taste, {})) | def _getFlavour(self, taste='html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ data = self._request.getData() config = self._request.getConfiguration() | |
if not flavour: return DEFAULT_FLAVOURS["error"] | def _getFlavour(self, taste='html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ data = self._request.getData() config = self._request.getConfiguration() | |
self.flavour = self._getFlavour(data.get('flavour', 'html')) | try: self.flavour = self._getFlavour(data.get('flavour', 'html')) except NoSuchFlavourException, nsfe: self.flavour = self._getFlavour("error") self._content = { "title": "Flavour error", "body": nsfe._msg } | def render(self, header = 1): """ Figures out flavours and such and then renders the content according to which flavour we're using. |
print "" print "*** Trackback " + url print parser.args | tools.log("") tools.log( "*** Trackback " + url) tools.log(parser.args) | def trackback(parser): """ parser -> None Ping all trackbacks encountered with the url, title, blog_name, and excerpt. """ for url in parser.trackbacks: try: print "" print "*** Trackback " + url print parser.args if url.find('?tb_id=') >= 0: file=urllib.urlopen(url + "&" + parser.args) else: file=urllib.urlopen(url,... |
print file.read() | tools.log(file.read()) | def trackback(parser): """ parser -> None Ping all trackbacks encountered with the url, title, blog_name, and excerpt. """ for url in parser.trackbacks: try: print "" print "*** Trackback " + url print parser.args if url.find('?tb_id=') >= 0: file=urllib.urlopen(url + "&" + parser.args) else: file=urllib.urlopen(url,... |
except: pass | except Exception, e: tools.log(e) | def trackback(parser): """ parser -> None Ping all trackbacks encountered with the url, title, blog_name, and excerpt. """ for url in parser.trackbacks: try: print "" print "*** Trackback " + url print parser.args if url.find('?tb_id=') >= 0: file=urllib.urlopen(url + "&" + parser.args) else: file=urllib.urlopen(url,... |
print "" print "*** Pingback " + server | tools.log("") tools.log("*** Pingback " + server) | def pingback(parser): """ parser -> None Ping all pingbacks encountered with the source and targets """ for target,server in parser.pingbacks: try: print "" print "*** Pingback " + server server=xmlrpclib.Server(server) print server.pingback.ping(parser.url,target) except: pass |
print server.pingback.ping(parser.url,target) except: pass | tools.log(server.pingback.ping(parser.url,target)) except Exception, e: tools.log(e) | def pingback(parser): """ parser -> None Ping all pingbacks encountered with the source and targets """ for target,server in parser.pingbacks: try: print "" print "*** Pingback " + server server=xmlrpclib.Server(server) print server.pingback.ping(parser.url,target) except: pass |
req = Request() cache = cache_driver.BlosxomCache(req, config.py.get('cacheConfig', '')) | cache = cache_driver.BlosxomCache(request, config.py.get('cacheConfig', '')) | def autoping(name): # Load up the cache (You can just import the base cache here) cache_driver = tools.importName('Pyblosxom.cache', config.py.get('cacheDriver', 'base')) req = Request() cache = cache_driver.BlosxomCache(req, config.py.get('cacheConfig', '')) try: filename = os.path.join(config.py['datadir'], name) ent... |
entryData = default_entry_parser(filename,req) except IOError: pass | entryData = blosxom_entry_parser(filename, request) except IOError, e: tools.log(e) | def autoping(name): # Load up the cache (You can just import the base cache here) cache_driver = tools.importName('Pyblosxom.cache', config.py.get('cacheDriver', 'base')) req = Request() cache = cache_driver.BlosxomCache(req, config.py.get('cacheConfig', '')) try: filename = os.path.join(config.py['datadir'], name) ent... |
except: pass | except Exception, e: tools.log(e) | def autoping(name): # Load up the cache (You can just import the base cache here) cache_driver = tools.importName('Pyblosxom.cache', config.py.get('cacheDriver', 'base')) req = Request() cache = cache_driver.BlosxomCache(req, config.py.get('cacheConfig', '')) try: filename = os.path.join(config.py['datadir'], name) ent... |
{'txt': PyBlosxom.defaultEntryParser}, | {'txt': p.defaultEntryParser}, | def fileFor(req, uri): config = req.getConfiguration() data = req.getData() # import plugins import libs.plugins.__init__ libs.plugins.__init__.initialize_plugins(config) # do start callback tools.run_callback("start", {'request': req}, mappingfunc=lambda x,y:y) req.addHttp({"form": cgi.FieldStorage()}) p = PyBlosx... |
'author':'Pingback', | 'author':'Pingback from %s' % source_page.title, | def pingback(request, source, target): source_file = urllib.urlopen(source.split('#')[0]) source_page = parser() source_page.feed(source_file.read()) source_file.close() if source_page.title == "": source_page.title = source if target in source_page.hrefs: target_file = fileFor(request, target) body = '' try: from r... |
from libs.plugins.commentdecorator import writeComment | from libs.plugins.comments import writeComment | def pingback(request, source, target): source_file = urllib.urlopen(source.split('#')[0]) source_page = parser() source_page.feed(source_file.read()) source_file.close() if source_page.title == "": source_page.title = source if target in source_page.hrefs: target_file = fileFor(request, target) body = '' try: from r... |
fixf("docs/README.contrib"), fixf("docs/README.plugins"), fixf("docs/ReadMeForPlugins.py")] def is_goodfile(path, f): if f in ["CVS"] or os.path.isdir(path + os.sep + f): return 0 return 1 | os.path.normpath("docs/README.contrib"), os.path.normpath("docs/README.plugins"), os.path.normpath("docs/ReadMeForPlugins.py")] | def Walk(root='.'): """ A really really scaled down version of what we have in tools.py. """ # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # check each file for name in names: fullname = os.path.normpath(os.path.join(root, name)) # recursively ... |
f = [mem + os.sep + m for m in f if is_goodfile(mem, m)] | f = [mem + os.sep + m for m in f if os.path.isfile(mem + os.sep + m)] | def is_goodfile(path, f): if f in ["CVS"] or os.path.isdir(path + os.sep + f): return 0 return 1 |
pydf=[ ("/usr/share/" + PVER + "/web", ["web/pyblosxom.cgi", "web/xmlrpc.cgi", "web/config.py"]), ("/usr/share/doc/" + PVER, doc_files) ] | pydf = [] | def is_goodfile(path, f): if f in ["CVS"] or os.path.isdir(path + os.sep + f): return 0 return 1 |
elist = [mem[len(root):] for mem in elist] | elist = [mem[len(root)+1:] for mem in elist] | def genCategories(self): config = self._request.getConfiguration() root = config["datadir"] |
""" Returns the filestat on a given file. We store the filestat in case we've already retrieved it this time. | data = request.getData() filestat_cache = data.setdefault("filestat_cache", {}) if filestat_cache.has_key(filename): return filestat_cache[filename] argdict = {"request": request, "filename": filename, "mtime": os.stat(filename)} argdict = run_callback("filestat", argdict, mappingfunc=lambda x,y:y, defaultfunc=lambda... | def filestat(request, filename): """ Returns the filestat on a given file. We store the filestat in case we've already retrieved it this time. @param request: the Pyblosxom Request object @type request: Request @param filename: the name of the file to stat @type filename: string @returns: the mtime of the file (s... |
@param request: the Pyblosxom Request object @type request: Request @param filename: the name of the file to stat @type filename: string @returns: the mtime of the file (same as returned by time.localtime(...)) @rtype: tuple of 9 ints """ data = request.getData() filestat_cache = data.setdefault("filestat_cache", {... | return timetuple | def filestat(request, filename): """ Returns the filestat on a given file. We store the filestat in case we've already retrieved it this time. @param request: the Pyblosxom Request object @type request: Request @param filename: the name of the file to stat @type filename: string @returns: the mtime of the file (s... |
>>> tools.make_logger('/tmp/pybloxom.log') >>> tools.log('log message') | -->>> tools.make_logger('/tmp/pybloxom.log') -->>> tools.log('log message') | def make_logger(filename): """ Create a logging function called log, which logs to the supplied filename usage is: >>> tools.make_logger('/tmp/pybloxom.log') >>> tools.log('log message') @param filename: the name of a file to log to @type filename: string """ global log try: import logging except ImportError: def log... |
out.write(self.read()) | try: out.write(self.read()) except IOError: pass | def sendBody(self, out): """ Send the response body to the given output stream. |
data['path_info'] = list(path_info) | data['path_info'] = path_info | def blosxom_process_path_info(args): """ Process HTTP PATH_INFO for URI according to path specifications, fill in data dict accordingly The paths specification looks like this: - C{/foo.html} and C{/cat/foo.html} - file foo.* in / and /cat - C{/cat} - category - C{/2002} - year - C{/2002/Feb} (or 02) - Year and Month ... |
if ext: | if newpath.endswith("/index") and ext: | def blosxom_process_path_info(args): """ Process HTTP PATH_INFO for URI according to path specifications, fill in data dict accordingly The paths specification looks like this: - C{/foo.html} and C{/cat/foo.html} - file foo.* in / and /cat - C{/cat} - category - C{/2002} - year - C{/2002/Feb} (or 02) - Year and Month ... |
flav = ext[1:] data["flavour"] = flav | data["flavour"] = ext[1:] | def blosxom_process_path_info(args): """ Process HTTP PATH_INFO for URI according to path specifications, fill in data dict accordingly The paths specification looks like this: - C{/foo.html} and C{/cat/foo.html} - file foo.* in / and /cat - C{/cat} - category - C{/2002} - year - C{/2002/Feb} (or 02) - Year and Month ... |
while not (len(path_info[0]) == 4 and path_info[0].isdigit()): | while len(path_info) > 0 and \ not (len(path_info[0]) == 4 and path_info[0].isdigit()): | def blosxom_process_path_info(args): """ Process HTTP PATH_INFO for URI according to path specifications, fill in data dict accordingly The paths specification looks like this: - C{/foo.html} and C{/cat/foo.html} - file foo.* in / and /cat - C{/cat} - category - C{/2002} - year - C{/2002/Feb} (or 02) - Year and Month ... |
return self._metadata.keys() + [CONTENT_KEY,] | keys = self.getMetadataKeys() keys.append(CONTENT_KEY) return keys | def keys(self): """ Returns a list of the keys that can be accessed through __getitem__. |
Each function tries to see if it can handle the data. If it can't, then it returns None. If it can, then it handles the data (possibly by converting it into something else) and then returns that data at which point the CallbackChain ceases and we return the result. | Each function tries to see if it can handle the data being passed in as input. If it can handle the data, then it does so and returns api.HANDLED. We continue through the list of registered functions until we hit the end (none of them handled it) or one of the functions has handled the data and we don't need to proce... | def executeHandler(self, data): """ Executes a callback chain on a given piece of data. This data could be a string or an object. Consult the documentation for the specific callback chain you're executing. |
data = mem(data) if data != None: return data | if mem(data) == HANDLED: break | def executeHandler(self, data): """ Executes a callback chain on a given piece of data. This data could be a string or an object. Consult the documentation for the specific callback chain you're executing. |
Changed data is returned by each function in the chain until the last function returns data--then that data is returned to the executor. | Each function of the chain takes the input, applies some transformation to it, and then returns the newly changed input as output. This output is then passed to the next function in the chain as input and we proceed until all registered functions have had a chance to operate on the data. We then return the data to th... | def executeChain(self, data): """ Executes a callback chain on a given piece of data. This data could be a string or an object. Consult the documentation for the specific callback chain you're executing. |
if data == None: return | def executeChain(self, data): """ Executes a callback chain on a given piece of data. This data could be a string or an object. Consult the documentation for the specific callback chain you're executing. | |
highlight[day] = tuple([1] + highlight[day][1:]) | highlight[day] = tuple([1] + list(highlight[day])[1:]) | def generateCalendar(self): """ Generates the calendar. We'd like to walk the archives for things that happen in this month and mark the dates accordingly. After doing that we pass it to a formatting method which turns the thing into HTML. """ root = self._py["datadir"] baseurl = self._py.get("base_url", "") markup =... |
if not type(s) == types.StringType: | if not isinstance(s, str): | def E(s): if not s: return "" if not type(s) == types.StringType: s = repr(s) return s.replace("&", "&").replace(">", ">").replace("<", "<") |
if type(content) != types.StringType: | if not isinstance(content, str): | def render(self, header = 1): pyhttp = self._request.getHttp() config = self._request.getConfiguration() data = self._request.getData() printout = self.write |
open(blogID, 'w').write(content) | open(blogID, 'w').write(content.encode(config['blog_encoding'])) | def blogger_newPost(request, appkey, blogid, username, password, content, publish=1): """ Used for creating new posts on the server """ authenticate(request, username, password) config = request.getConfiguration() if os.path.isdir(os.path.normpath(os.path.join(config['datadir'], blogid[1:]))): # Look at content blogTi... |
bad_list = string.split(self._config.get('refer_blacklist',''),',') | list = self._config.get('refer_blacklist','') if list: bad_list = string.split(list,',') else: bad_list = [] | def genReferrers(self): """ Generate the list of referring files """ # initialize blacklist bad_list = string.split(self._config.get('refer_blacklist',''),',') |
return '<a href="'+uri+'" title="'+uri+'">'+vis+' ('+str(count)+')'+'</a><br />\n' | return ("""<a href="%(uri)s" title="%(uri)s">%(vis)s (%(count)d)</a><br />\n""" % {'uri': uri, 'vis': vis, 'count': count}) | def url(tuple): """ Markup (and truncate) a referrer URL """ uri = tuple[0] count = tuple[1] size = 32 vis = uri if len(bad_list) > 0: for pat in bad_list: if re.search(pat, uri): return "" if len(uri) > size: vis = vis[:size]+'...' return '<a href="'+uri+'" title="'+uri+'">'+vis+' ('+str(count)+')'+'</a><br />\n' |
log_name = "" | custom_log_file = True log_name = os.path.splitext(os.path.basename(log_file))[0] | def getLogger(log_file=None): """ Creates and retuns a log channel. If no log_file is given the system-wide logfile as defined in config.py is used. If a log_file is given that's where the created logger logs to. @param log_file: optional, the file to log to. @type log_file: C{str} @return: a log channel (Logger insta... |
log_filter = _config.get('log_filter', None) if log_filter: orig_log = logger._log def _log(self, level, msg, args, exc_info=None): if log_name in log_filter or (log_name == "" and 'root' in log_filter): orig_log(level, msg, args, exc_info) import new logger._log = new.instancemethod(_log, logger, logger.__class__) | if not custom_log_file: log_filter = _config.get('log_filter', None) if log_filter: filter = LogFilter(log_filter) logger.addFilter(filter) | def getLogger(log_file=None): """ Creates and retuns a log channel. If no log_file is given the system-wide logfile as defined in config.py is used. If a log_file is given that's where the created logger logs to. @param log_file: optional, the file to log to. @type log_file: C{str} @return: a log channel (Logger insta... |
self._filename = filename self._root = root | self._filename = filename.replace('\\', '/') self._root = root.replace('\\', '/') | def __init__(self, request, filename, root, datadir=""): """ @param request: the Request object @type request: Request |
temp = os.path.dirname(mem).split(os.sep) for i in range(len(temp)+1): p = os.sep.join(temp[0:i]) categories[p] = 0 | def runStaticRenderer(self): """ This will go through all possible things in the blog and statically render everything to the "static_dir" specified in the config file. | |
renderme.append( (mem + "." + flavours[0], fn + "." + flavours[0]) ) | try: smtime = os.stat(fn + "." + flavours[0])[8] except: smtime = 0 if smtime < mtime: temp = os.path.dirname(mem).split(os.sep) for i in range(len(temp)+1): p = os.sep.join(temp[0:i]) categories[p] = 0 mtime = time.localtime(mtime) year = time.strftime("%Y", mtime) month = time.strftime("%m", mtime) day = time.s... | def runStaticRenderer(self): """ This will go through all possible things in the blog and statically render everything to the "static_dir" specified in the config file. |
print "category: %s" % mem | def runStaticRenderer(self): """ This will go through all possible things in the blog and statically render everything to the "static_dir" specified in the config file. | |
dates = dates.keys() dates.sort() print "rendering %d date indexes." % len(dates) for mem in dates: for f in flavours: fn = os.path.normpath(staticdir + mem + os.sep + "index") renderme.append( (mem + "?flav=" + f, fn + "." + f) ) | def runStaticRenderer(self): """ This will go through all possible things in the blog and statically render everything to the "static_dir" specified in the config file. | |
print "rendering: %s -> %s ..." % (path, fn) | def runStaticRenderer(self): """ This will go through all possible things in the blog and statically render everything to the "static_dir" specified in the config file. | |
def __init__(self): | def __init__(self, config): self._config = config | def __init__(self): self._data = None self._metadata = {} |
def getId(self): | def getMetadata(self, key, default=None): | def getId(self): """ This should return an id that's unique enough for caching purposes. |
This should return an id that's unique enough for caching purposes. | Returns a given piece of metadata. | def getId(self): """ This should return an id that's unique enough for caching purposes. |
Override this. | @param key: the key being sought @type key: varies | def getId(self): """ This should return an id that's unique enough for caching purposes. |
@returns: string id @rtype: string | @param default: the default to return if the key does not exist @type default: varies @return: either the default (if the key did not exist) or the value of the key in the metadata dict @rtype: varies | def getId(self): """ This should return an id that's unique enough for caching purposes. |
return "" | return self._metadata.get(key, default) def setMetadata(self, key, value): """ Sets a key/value pair in the metadata dict. """ self._metadata[key] = value | def getId(self): """ This should return an id that's unique enough for caching purposes. |
return self._metadata.get(key, default) | return self.getMetadata(key, default) | def __getitem__(self, key, default=None): """ Retrieves an item from this dict based on the key given. If the item does not exist, then we return the default. If the item is CONTENT_KEY then we return the result from self.getData(). |
Note: using the key CONTENT_KEY is probably not a good idea. | This is a convenience method for setData(...) and setMetadata(...). There's no reason to override this. Override setData and setMetadata. | def __setitem__(self, key, value): """ Sets the metadata[key] to the given value. |
self._metadata[key] = value def __delitem__(self, key): del self._metadata[key] | if key == CONTENT_KEY: self.setData(value) else: self.setMetadata(key, value) | def __setitem__(self, key, value): """ Sets the metadata[key] to the given value. |
return self._metadata.has_key(key) | value = self.getMetadata(key, DOESNOTEXIST) if value == DOESNOTEXIST: return 0 return 1 | def has_key(self, key): """ Returns whether a given key is in the metadata dict. If the key is the CONTENT_KEY, then we automatically return true. |
self._original_metadata_keys = [] | def __init__(self, config, filename, root): base.EntryBase.__init__(self) self._config = config self._filename = filename self._root = root | |
self._populated_data = 0 | def __init__(self, config, filename, root): base.EntryBase.__init__(self) self._config = config self._filename = filename self._root = root | |
while lines[0].startswith(" | while lines and lines[0].startswith(" | def blosxom_entry_parser(filename, request): """ Open up a *.txt file and read its contents. The first line becomes the title of the entry. The other lines are the body of the entry. @param filename: A filename to extract data and metadata from @type filename: string @param request: A standard request object @type ... |
% (data["base_url"], config["blog_title"])}) | % (config["base_url"], config["blog_title"])}) | def run(self): """Main loop for pyblosxom""" config = self._request.getConfiguration() data = self._request.getData() |
data["bl_type"] = "file" | data["bl_type"] = "dir" | def blosxom_process_path_info(args): """ Process HTTP PATH_INFO for URI according to path specifications, fill in data dict accordingly The paths specification looks like this: - C{/foo.html} and C{/cat/foo.html} - file foo.* in / and /cat - C{/cat} - category - C{/2002} - year - C{/2002/Feb} (or 02) - Year and Month ... |
def fixf(f): return f.replace("/", os.sep) | fixf = os.path.normpath | def fixf(f): return f.replace("/", os.sep) |
scripts=['web/pyblosxom.cgi', 'web/xmlrpc.cgi'], | def Walk(root='.'): """ A really really scaled down version of what we have in tools.py. """ # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # check each file for name in names: fullname = os.path.normpath(os.path.join(root, name)) # recursively ... | |
path = path[1:][:-1] | path = path[:-1] | def __populateBasicMetadata(self): """ Fills the metadata dict with metadata about the given file. This metadata consists of things we pick up from an os.stat call as well as knowledge of the filename and the root directory. The rest of the metadata comes from parsing the file itself which is done with __populateData.... |
fn = re.sub(r'\.txt$', '', file_basename) | ext = '|'.join(data['extensions'].keys()) fn = re.sub(r'\.(' + ext + ')$', '', file_basename) | def __populateBasicMetadata(self): """ Fills the metadata dict with metadata about the given file. This metadata consists of things we pick up from an os.stat call as well as knowledge of the filename and the root directory. The rest of the metadata comes from parsing the file itself which is done with __populateData.... |
input = self.getHttp()['wsgi.input'] self._in.write(input.read()) self._in.seek(0) | pyhttp = self.getHttp() input = pyhttp['wsgi.input'] method = pyhttp["REQUEST_METHOD"] if method != "GET": self._in.write(input.read()) self._in.seek(0) | def buffer_input_stream(self): """ Buffer the input stream in a StringIO instance. This is done to have a known/consistent way of accessing incomming data. For example the input stream passed by mod_python does not offer the same functionallity as sys.stdin. """ # TODO: tests on memory consumption when uploading huge f... |
data['url'] = '%s%s' % (config['base_url'], data['pi_bl']) | else: config['base_url'] = config.get('base_url', '') | def startup(self): """ The startup step further initializes the Request by setting additional information in the _data dict. """ data = self._request.getData() pyhttp = self._request.getHttp() config = self._request.getConfiguration() |
temp = tools.month2num[temp] | temp = int(tools.month2num[temp]) | def generateCalendar(self): """ Generates the calendar. We'd like to walk the archives for things that happen in this month and mark the dates accordingly. And possibly turn this into a table with CSS markup and such. """ root = self._py["datadir"] baseurl = self._py.get("base_url", "") markup = self._py.get("calenda... |
if config['num_entries']: | if config.get('num_entries', 0): | def blosxom_file_list_handler(args): """ This is the default handler for getting entries. It takes the request object in and figures out which entries based on the default behavior that we want to show and generates a list of EntryBase subclass objects which it returns. @param args: dict containing the incoming Reque... |
if self._py.has_key('refer_blacklist'): bad_list = string.split(self._py['refer_blacklist'],',') for pat in bad_list: if re.search(pat, url): return | def addReferer(self, uri): # process - if uri == '-': return | |
size = 40 | size = 32 | def url(tuple): """ Markup (and truncate) a referrer URL """ uri = tuple[0] count = tuple[1] size = 40 vis = uri # process blacklist if self._py.has_key('refer_blacklist'): bad_list = string.split(self._py['refer_blacklist'],',') for pat in bad_list: if re.search(pat, uri): return "" if len(uri) > size: vis = vis[:size... |
if self._py.has_key('refer_blacklist'): bad_list = string.split(self._py['refer_blacklist'],',') | if len(bad_list) > 0: | def url(tuple): """ Markup (and truncate) a referrer URL """ uri = tuple[0] count = tuple[1] size = 40 vis = uri # process blacklist if self._py.has_key('refer_blacklist'): bad_list = string.split(self._py['refer_blacklist'],',') for pat in bad_list: if re.search(pat, uri): return "" if len(uri) > size: vis = vis[:size... |
return '<a href="'+uri+'" title="'+uri+'">'+vis+' ('+str(count)+')'+'</a><br />' | return '<a href="'+uri+'" title="'+uri+'">'+vis+' ('+str(count)+')'+'</a><br />\n' | def url(tuple): """ Markup (and truncate) a referrer URL """ uri = tuple[0] count = tuple[1] size = 40 vis = uri # process blacklist if self._py.has_key('refer_blacklist'): bad_list = string.split(self._py['refer_blacklist'],',') for pat in bad_list: if re.search(pat, uri): return "" if len(uri) > size: vis = vis[:size... |
refs = items[0:14] | refs = [ url(x) for x in items ] refs = [ x for x in refs if x != "" ] | def compareCounts(tuple1, tuple2): count1 = tuple1[1] count2 = tuple2[1] if count1 > count2: return -1 # reverse order if count1 < count2: return 1 return 0 |
self._referrersText = string.join([ url(x) for x in refs ]) | self._referrersText = string.join(refs[0:24]) | def compareCounts(tuple1, tuple2): count1 = tuple1[1] count2 = tuple2[1] if count1 > count2: return -1 # reverse order if count1 < count2: return 1 return 0 |
renderer.showHeader() | renderer.showHeaders() | def cb_start(args): req = args['request'] renderer = req['renderer'] |
self.showHeader() | self.showHeaders() | def render(self, header = 1): """ Do final rendering. |
for content in contents: | for content in self._content: | def render(self, header = 1): print "Content-Type: text/plain\n" print "Welcome to debug mode!" print "You wanted the %(flavour)s flavour if I support flavours" % self._py |
def __init__(self, config): | def __init__(self, config={}): | def __init__(self, config): self._config = config self._data = None self._metadata = {} |
def setData(self): self._child.setData() | def setData(self, data): self._child.setData(data) | def setData(self): self._child.setData() |
root = "/usr/share/" + PVER + "/" | def Walk(root='.'): """ A really really scaled down version of what we have in tools.py. """ # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # check each file for name in names: if name == "CVS": continue fullname = os.path.normpath(os.path.join(r... | |
f = [mem + os.sep + m for m in f if os.path.isfile(mem + os.sep + m)] pydf.append( (root + mem, f) ) | f = [os.path.join(mem, m) for m in f if os.path.isfile(os.path.join(mem, m))] pydf.append( (os.path.join('share', PVER, mem), f) ) | def Walk(root='.'): """ A really really scaled down version of what we have in tools.py. """ # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # check each file for name in names: if name == "CVS": continue fullname = os.path.normpath(os.path.join(r... |
web_files = [os.path.normpath("web/pyblosxom.cgi"), os.path.normpath("web/config.py")] pydf.append( ("/usr/share/" + PVER + "/web", web_files) ) | pydf.append( [os.path.join('share', PVER, 'web'), [os.path.normpath("web/pyblosxom.cgi"), os.path.normpath("web/config.py")]]) | def Walk(root='.'): """ A really really scaled down version of what we have in tools.py. """ # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # check each file for name in names: if name == "CVS": continue fullname = os.path.normpath(os.path.join(r... |
""" | """cvs | def cb_prepare(args): """ Handle comment related HTTP POST's @param request: pyblosxom request object @type request: a Pyblosxom request object """ request = args["request"] form = request.getHttp()['form'] config = request.getConfiguration() data = request.getData() if form.has_key("title") and form.has_key("author"... |
return template +u"".join(output) | dict['template'] = template +u"".join(output) | def cb_story(dict): renderer = dict['renderer'] entry = dict['entry'] template = dict['template'] if len(renderer.getContent()) == 1: template = renderer.flavour.get('comment-story','') output = [] if entry.has_key('comments'): for comment in entry['comments']: renderer.outputTemplate(output, comment, 'comment') render... |
'head' : """title: $blog_title\ndescription: $blog_description\nlink: $url\ncreator: wari@wari.per.sg Wari Wahab\nerrorsTo: wari@wari.per.sg Wari Wahab\nlang: $blog_language\n\n""", 'story' : """title: $title\nlink: $base_url/$file_path.html\ncreated: $w3cdate\nsubject: $path\nguid: $file_path\n""", | 'head' : """title: $blog_title\ndescription: $blog_description\nlink: $url\ncreator: wari@wari.per.sg Wari Wahab\nerrorsTo: wari@wari.per.sg Wari Wahab\nlang: $blog_language\n\n\n""", 'story' : """title: $title\nlink: $base_url/$file_path.html\ncreated: $w3cdate\nsubject: $path\nguid: $file_path\n\n""", | def __getFlavour(self, taste = 'html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ # Ugly default templates, have to though :( html = {'content_type' : ... |
'head' : """title: $blog_title\ncontact: contact@example.com (The Contact Person)\nlink: $url\n\n""", 'story' : """$mtime\t$title\t$base_url/$file_path""", | 'head' : """title: $blog_title\ncontact: contact@example.com (The Contact Person)\nlink: $url\n\n\n""", 'story' : """$mtime\t$title\t$base_url/$file_path\n""", | def __getFlavour(self, taste = 'html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ # Ugly default templates, have to though :( html = {'content_type' : ... |
flavours[flavouring[1]][flavouring[0]] = file(filename).read().strip() | flavours[flavouring[1]][flavouring[0]] = file(filename).read() | def __getFlavour(self, taste = 'html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ # Ugly default templates, have to though :( html = {'content_type' : ... |
flavours[flavouring[1]] = { flavouring[0] : file(filename).read().strip() } | flavours[flavouring[1]] = { flavouring[0] : file(filename).read() } | def __getFlavour(self, taste = 'html'): """ Flavours, or views, or templates, as some may call it, defaults are given, but can be overidden with files on the datadir. Don't like the default html templates, add your own, head.html, story.html etc. """ # Ugly default templates, have to though :( html = {'content_type' : ... |
extendedbody = sections[2].split(":",1)[1] | extendedbody = "" if len(sections) > 2: print sections extendedbody = sections[2].split(":",1)[1] | def convert(inputfile, outputdir): input = open(inputfile).read() entries = entryDelim.split(input) for entry in entries: if entry.strip(): sections = sectionDelim.split(entry) body = sections[1].split(":",1)[1] extendedbody = sections[2].split(":",1)[1] fields = sections[0].strip().split("\n") publish = 0 for field in... |
timestamp = time.mktime(time.strptime(date, "%m/%d/%Y %H:%M:%S %p")) | output_directory = output_dir_root+"/"+category if not os.path.exists(output_directory): os.mkdir(output_directory, 0755) | def convert(inputfile, outputdir): input = open(inputfile).read() entries = entryDelim.split(input) for entry in entries: if entry.strip(): sections = sectionDelim.split(entry) body = sections[1].split(":",1)[1] extendedbody = sections[2].split(":",1)[1] fields = sections[0].strip().split("\n") publish = 0 for field in... |
outputfile= "%s/%s" % (outputdir, re.sub(r"[^a-zA-Z0-9]", "_", outputfile)) | outputfile= "%s/%s" % (output_directory, re.sub(r"[^a-zA-Z0-9]", "_", outputfile)) | def convert(inputfile, outputdir): input = open(inputfile).read() entries = entryDelim.split(input) for entry in entries: if entry.strip(): sections = sectionDelim.split(entry) body = sections[1].split(":",1)[1] extendedbody = sections[2].split(":",1)[1] fields = sections[0].strip().split("\n") publish = 0 for field in... |
inputfile, outputdir = sys.argv[1:] | inputfile, output_dir_root = sys.argv[1:] | def convert(inputfile, outputdir): input = open(inputfile).read() entries = entryDelim.split(input) for entry in entries: if entry.strip(): sections = sectionDelim.split(entry) body = sections[1].split(":",1)[1] extendedbody = sections[2].split(":",1)[1] fields = sections[0].strip().split("\n") publish = 0 for field in... |
convert(inputfile, outputdir) | convert(inputfile, output_dir_root) | def convert(inputfile, outputdir): input = open(inputfile).read() entries = entryDelim.split(input) for entry in entries: if entry.strip(): sections = sectionDelim.split(entry) body = sections[1].split(":",1)[1] extendedbody = sections[2].split(":",1)[1] fields = sections[0].strip().split("\n") publish = 0 for field in... |
while re.match(r'^[a-zA-Z]\w*', path_info[0]): | while re.match(r'^[a-zA-Z0-9]\w*', path_info[0]): | def startup(self): self.py['pi_bl'] = '' path_info = [] |
'file_path' : absolute_path + '/' + fn, | 'file_path' : file_path, | def getProperties(self, filename, root): """Returns a dictionary of file related contents""" mtime = tools.filestat(filename)[8] timetuple = time.localtime(mtime) path = string.replace(filename, root, '') path = string.replace(path, os.path.basename(filename), '') path = path[1:][:-1] absolute_path = string.replace(fil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.