Merge branch 'dev' of github.com:beardog108/onionr into refactoring2

master
Kevin Froman 2018-06-08 01:15:47 -05:00
commit 2703731053
2 changed files with 10 additions and 3 deletions

View File

@ -475,7 +475,7 @@ class Onionr:
with open(plugins.get_plugins_folder(plugin_name) + '/main.py', 'a') as main: with open(plugins.get_plugins_folder(plugin_name) + '/main.py', 'a') as main:
contents = '' contents = ''
with open('static-data/default_plugin.py', 'rb') as file: with open('static-data/default_plugin.py', 'rb') as file:
contents = file.read() contents = file.read().decode()
# TODO: Fix $user. os.getlogin() is B U G G Y # TODO: Fix $user. os.getlogin() is B U G G Y
main.write(contents.replace('$user', 'some random developer').replace('$date', datetime.datetime.now().strftime('%Y-%m-%d')).replace('$name', plugin_name)) main.write(contents.replace('$user', 'some random developer').replace('$date', datetime.datetime.now().strftime('%Y-%m-%d')).replace('$name', plugin_name))

View File

@ -111,7 +111,7 @@ class Block:
self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')]) self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')])
self.bcontent = self.getRaw()[self.getRaw().index('\n') + 1:] self.bcontent = self.getRaw()[self.getRaw().index('\n') + 1:]
self.bmetadata = json.loads(self.getHeader('meta')) self.bmetadata = json.loads(self.getHeader('meta'))
self.parent = (None if not 'parent' in self.getMetadata() else Block(self.getMetadata('parent'))) self.parent = (None if not 'parent' in self.getMetadata() else self.getMetadata('parent'))
self.btype = self.getMetadata('type') self.btype = self.getMetadata('type')
self.powHash = self.getMetadata('powHash') self.powHash = self.getMetadata('powHash')
self.powToken = self.getMetadata('powToken') self.powToken = self.getMetadata('powToken')
@ -263,6 +263,14 @@ class Block:
- (Block): the Block's parent - (Block): the Block's parent
''' '''
if type(self.parent) == str:
if self.parent == self.getHash():
self.parent = self
elif Block.exists(self.parent):
self.parent = Block(self.getMetadata('parent'))
else:
self.parent = None
return self.parent return self.parent
def getDate(self): def getDate(self):
@ -459,7 +467,6 @@ class Block:
if relevant: if relevant:
relevant_blocks.append(block) relevant_blocks.append(block)
if bool(reverse): if bool(reverse):
relevant_blocks.reverse() relevant_blocks.reverse()