def _set_num_copies(self): from repository.models import git_annex_where_is data = git_annex_where_is(self) try: whereis = json.loads(data) self.num_copies = len(whereis[u'whereis']) except ValueError: self.num_copies = 1
def where_is(self): from repository.models import git_annex_where_is data = git_annex_where_is(self) whereis = json.loads(data) index = 0 for item in whereis["whereis"]: # strip [ or ] (prevent errors of getting mucuas address like [dpadua]) mucua_name = re.sub("[\[\]]", "", item["description"]).split(" ")[0] whereis["whereis"][index]["description"] = mucua_name index += 1 return whereis
def where_is(self): from repository.models import git_annex_where_is data = git_annex_where_is(self) whereis = json.loads(data) index = 0 for item in whereis['whereis']: # strip [ or ] (prevent errors of getting mucuas address like [dpadua]) mucua_name = re.sub("[\[\]]", "", item['description']).split(' ')[0] whereis['whereis'][index]['description'] = mucua_name index += 1 return whereis
def where_is(self): from repository.models import git_annex_where_is data = git_annex_where_is(self) try: whereis = json.loads(data) except ValueError: logger.debug("Data error " + data) whereis = { 'whereis': [] } index = 0 for item in whereis['whereis']: # strip [ or ] (prevent errors of getting mucuas address like [dpadua]) mucua_name = re.sub("[\[\]]", "", item['description']).split(' ')[0] whereis['whereis'][index]['description'] = mucua_name index += 1 return whereis
def where_is(self): from repository.models import git_annex_where_is return git_annex_where_is(self)
def _set_num_copies(self): from repository.models import git_annex_where_is import json data = git_annex_where_is(self) whereis = json.loads(data) self.num_copies = len(whereis[u'whereis'])