massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -50,7 +50,7 @@ LONG_DESC = D_(
|
|||
To use it, you'll need to export your blog to a flat file.
|
||||
You must go in your admin interface and select Plugins/Maintenance then Backup.
|
||||
Export only one blog if you have many, i.e. select "Download database of current blog"
|
||||
Depending on your configuration, your may need to use Import/Export plugin and export as a flat file.
|
||||
Depending on your configuration, your may need to use import/Export plugin and export as a flat file.
|
||||
|
||||
location: you must use the absolute path to your backup for the location parameter
|
||||
"""
|
||||
|
|
@ -77,7 +77,7 @@ class DotclearParser(object):
|
|||
self.posts_data = OrderedDict()
|
||||
self.tags = {}
|
||||
|
||||
def getPostId(self, post):
|
||||
def get_post_id(self, post):
|
||||
"""Return a unique and constant post id
|
||||
|
||||
@param post(dict): parsed post data
|
||||
|
|
@ -91,7 +91,7 @@ class DotclearParser(object):
|
|||
post["post_url"],
|
||||
)
|
||||
|
||||
def getCommentId(self, comment):
|
||||
def get_comment_id(self, comment):
|
||||
"""Return a unique and constant comment id
|
||||
|
||||
@param comment(dict): parsed comment
|
||||
|
|
@ -110,7 +110,7 @@ class DotclearParser(object):
|
|||
"""
|
||||
return time.mktime(time.strptime(data[key], "%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
def readFields(self, fields_data):
|
||||
def read_fields(self, fields_data):
|
||||
buf = []
|
||||
idx = 0
|
||||
while True:
|
||||
|
|
@ -148,13 +148,13 @@ class DotclearParser(object):
|
|||
buf.append(char)
|
||||
|
||||
def parseFields(self, headers, data):
|
||||
return dict(zip(headers, self.readFields(data)))
|
||||
return dict(zip(headers, self.read_fields(data)))
|
||||
|
||||
def postHandler(self, headers, data, index):
|
||||
def post_handler(self, headers, data, index):
|
||||
post = self.parseFields(headers, data)
|
||||
log.debug("({}) post found: {}".format(index, post["post_title"]))
|
||||
mb_data = {
|
||||
"id": self.getPostId(post),
|
||||
"id": self.get_post_id(post),
|
||||
"published": self.getTime(post, "post_creadt"),
|
||||
"updated": self.getTime(post, "post_upddt"),
|
||||
"author": post["user_id"], # there use info are not in the archive
|
||||
|
|
@ -163,7 +163,7 @@ class DotclearParser(object):
|
|||
post["post_content_xhtml"], post["post_excerpt_xhtml"]
|
||||
),
|
||||
"title": post["post_title"],
|
||||
"allow_comments": C.boolConst(bool(int(post["post_open_comment"]))),
|
||||
"allow_comments": C.bool_const(bool(int(post["post_open_comment"]))),
|
||||
}
|
||||
self.posts_data[post["post_id"]] = {
|
||||
"blog": mb_data,
|
||||
|
|
@ -171,18 +171,18 @@ class DotclearParser(object):
|
|||
"url": "/post/{}".format(post["post_url"]),
|
||||
}
|
||||
|
||||
def metaHandler(self, headers, data, index):
|
||||
def meta_handler(self, headers, data, index):
|
||||
meta = self.parseFields(headers, data)
|
||||
if meta["meta_type"] == "tag":
|
||||
tags = self.tags.setdefault(meta["post_id"], set())
|
||||
tags.add(meta["meta_id"])
|
||||
|
||||
def metaFinishedHandler(self):
|
||||
def meta_finished_handler(self):
|
||||
for post_id, tags in self.tags.items():
|
||||
data_format.iter2dict("tag", tags, self.posts_data[post_id]["blog"])
|
||||
del self.tags
|
||||
|
||||
def commentHandler(self, headers, data, index):
|
||||
def comment_handler(self, headers, data, index):
|
||||
comment = self.parseFields(headers, data)
|
||||
if comment["comment_site"]:
|
||||
# we don't use atom:uri because it's used for jid in XMPP
|
||||
|
|
@ -193,7 +193,7 @@ class DotclearParser(object):
|
|||
else:
|
||||
content = comment["comment_content"]
|
||||
mb_data = {
|
||||
"id": self.getCommentId(comment),
|
||||
"id": self.get_comment_id(comment),
|
||||
"published": self.getTime(comment, "comment_dt"),
|
||||
"updated": self.getTime(comment, "comment_upddt"),
|
||||
"author": comment["comment_author"],
|
||||
|
|
@ -263,13 +263,13 @@ class DotclearParser(object):
|
|||
|
||||
class DotclearImport(object):
|
||||
def __init__(self, host):
|
||||
log.info(_("plugin Dotclear Import initialization"))
|
||||
log.info(_("plugin Dotclear import initialization"))
|
||||
self.host = host
|
||||
host.plugins["BLOG_IMPORT"].register(
|
||||
"dotclear", self.DcImport, SHORT_DESC, LONG_DESC
|
||||
"dotclear", self.dc_import, SHORT_DESC, LONG_DESC
|
||||
)
|
||||
|
||||
def DcImport(self, client, location, options=None):
|
||||
def dc_import(self, client, location, options=None):
|
||||
if not os.path.isabs(location):
|
||||
raise exceptions.DataError(
|
||||
"An absolute path to backup data need to be given as location"
|
||||
|
|
|
|||
Loading…
Reference in a new issue