Commit af0391aa authored by Mathieu Giraud's avatar Mathieu Giraud

tools/analysis.py: loads analysis

parent b3665a70
import json
from utils import *
from defs import *
class Analysis(VidjilJson):
def __init__(self):
self.clones = {}
def load(self, file_path):
with open(file_path, "r") as f:
tmp = json.load(f) # , object_hook=self.toPython)
self.d = tmp
self.check_version(file_path)
for clone in self.d['clones']:
self.clones[clone['id']] = clone
VIDJIL_JSON_VERSION = "2014.10"
...@@ -40,8 +40,8 @@ import subprocess ...@@ -40,8 +40,8 @@ import subprocess
import tempfile import tempfile
from operator import itemgetter from operator import itemgetter
from utils import * from utils import *
from defs import *
VIDJIL_JSON_VERSION = "2014.10"
FUSE_VERSION = "vidjil fuse" FUSE_VERSION = "vidjil fuse"
TOOL_SIMILARITY = "../algo/tools/similarity" TOOL_SIMILARITY = "../algo/tools/similarity"
...@@ -213,7 +213,7 @@ class OtherWindows: ...@@ -213,7 +213,7 @@ class OtherWindows:
print(' --[others]-->', w) print(' --[others]-->', w)
yield w yield w
class ListWindows: class ListWindows(VidjilJson):
'''storage class for sequences informations '''storage class for sequences informations
>>> lw1.info() >>> lw1.info()
...@@ -278,13 +278,6 @@ class ListWindows: ...@@ -278,13 +278,6 @@ class ListWindows:
print(self) print(self)
for clone in self: for clone in self:
print(clone) print(clone)
### check vidjil_json_version
def check_version(self, filepath):
if "vidjil_json_version" in self.d:
if self.d["vidjil_json_version"] <= VIDJIL_JSON_VERSION:
return
raise IOError ("File '%s' is too old -- please regenerate it with a newer version of Vidjil" % filepath)
### compute statistics about clones ### compute statistics about clones
def build_stat(self): def build_stat(self):
......
import collections import collections
import defs
#### Utilities on dictionaries #### Utilities on dictionaries
...@@ -193,3 +193,17 @@ def interesting_substrings(l, target_length=6, substring_replacement='-'): ...@@ -193,3 +193,17 @@ def interesting_substrings(l, target_length=6, substring_replacement='-'):
# return substrings # return substrings
#########
class VidjilJson():
def check_version(self, filepath):
'''Check vidjil_json_version'''
if "vidjil_json_version" in self.d:
if self.d["vidjil_json_version"] <= defs.VIDJIL_JSON_VERSION:
return
raise IOError ("File '%s' is too old -- please regenerate it with a newer version of Vidjil" % filepath)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment