fic: Make pep8 happy

pull/227/head
Raphaël Vinot 2020-01-30 11:38:56 +01:00
parent 8d01493a97
commit 620ac3600c
1 changed files with 16 additions and 12 deletions

View File

@ -39,6 +39,7 @@ argParser = argparse.ArgumentParser(description='Generate documentation from MIS
argParser.add_argument('-v', action='store_true', help='Verbose mode') argParser.add_argument('-v', action='store_true', help='Verbose mode')
args = argParser.parse_args() args = argParser.parse_args()
def header(adoc=False): def header(adoc=False):
if adoc is False: if adoc is False:
return False return False
@ -66,25 +67,26 @@ def header(adoc=False):
doc = doc + "= MISP objects\n" doc = doc + "= MISP objects\n"
return doc return doc
def asciidoc(content=False, adoc=None, t='title',title=''):
def asciidoc(content=False, adoc=None, t='title', title=''):
adoc = adoc + "\n" adoc = adoc + "\n"
output = "" output = ""
if t == 'title': if t == 'title':
output = '== ' + content output = '== ' + content
elif t == 'info': elif t == 'info':
content = content.rstrip('\.') content = content.rstrip('.')
output = "\n{}.\n\n{} {} {}{}/definition.json[*this location*] {}.\n".format(content, 'NOTE: ', title, 'is a MISP object available in JSON format at https://github.com/MISP/misp-objects/blob/master/objects/',title.lower(),' The JSON format can be freely reused in your application or automatically enabled in https://www.github.com/MISP/MISP[MISP]') output = "\n{}.\n\n{} {} {}{}/definition.json[*this location*] {}.\n".format(content, 'NOTE: ', title, 'is a MISP object available in JSON format at https://github.com/MISP/misp-objects/blob/master/objects/', title.lower(), ' The JSON format can be freely reused in your application or automatically enabled in https://www.github.com/MISP/MISP[MISP]')
elif t == 'author': elif t == 'author':
output = '\nauthors:: {}\n'.format(' - '.join(content)) output = '\nauthors:: {}\n'.format(' - '.join(content))
elif t == 'value': elif t == 'value':
output = '=== ' + content output = '=== ' + content
elif t == 'description': elif t == 'description':
content = content.rstrip('\.') content = content.rstrip('.')
output = '\n{}\n'.format(content) output = '\n{}\n'.format(content)
elif t == 'attributes': elif t == 'attributes':
#output = '\n{}\n'.format # output = '\n{}\n'.format
#output = '[cols=\",a\"]\n' # output = '[cols=\",a\"]\n'
output = output + '|===\n' output = output + '|===\n'
output = output + '|Object attribute | MISP attribute type | Description | Disable correlation | Multiple\n' output = output + '|Object attribute | MISP attribute type | Description | Disable correlation | Multiple\n'
adoc = adoc + output adoc = adoc + output
@ -103,21 +105,22 @@ def asciidoc(content=False, adoc=None, t='title',title=''):
description = '{}'.format(content['attributes'][v]['description']) description = '{}'.format(content['attributes'][v]['description'])
if 'values_list' in content['attributes'][v]: if 'values_list' in content['attributes'][v]:
values = content['attributes'][v]['values_list'] values = content['attributes'][v]['values_list']
description = '{} {}'.format(content['attributes'][v]['description'],values) description = '{} {}'.format(content['attributes'][v]['description'], values)
if 'sane_default' in content['attributes'][v]: if 'sane_default' in content['attributes'][v]:
values = content['attributes'][v]['sane_default'] values = content['attributes'][v]['sane_default']
description = '{} {}'.format(content['attributes'][v]['description'],values) description = '{} {}'.format(content['attributes'][v]['description'], values)
output = '\n| {} | {} a| {} a| {} a| {}\n'.format(v, content['attributes'][v]['misp-attribute'], description ,disableCorrelation, multiple) output = '\n| {} | {} a| {} a| {} a| {}\n'.format(v, content['attributes'][v]['misp-attribute'], description, disableCorrelation, multiple)
adoc = adoc + output adoc = adoc + output
output = '\n|===\n' output = '\n|===\n'
adoc = adoc + output adoc = adoc + output
return adoc return adoc
adoc = "" adoc = ""
print (header(adoc=adoc)) print(header(adoc=adoc))
for mispobject in objects: for mispobject in objects:
fullPathClusters = os.path.join(pathObjects, '{}/{}'.format(mispobject,'definition.json')) fullPathClusters = os.path.join(pathObjects, '{}/{}'.format(mispobject, 'definition.json'))
with open(fullPathClusters) as fp: with open(fullPathClusters) as fp:
c = json.load(fp) c = json.load(fp)
title = c['name'] title = c['name']
@ -138,4 +141,5 @@ with open('../relationships/definition.json') as filerelationships:
output = output + '\n|===\n' output = output + '\n|===\n'
adoc = adoc + output adoc = adoc + output
print (adoc)
print(adoc)