# Path: odpw/core/licenses_mapping.py
# class LicensesOpennessMapping:
# 
#     __licenses_list=None
# 
#     def __init__(self):
#         if not LicensesOpennessMapping.__licenses_list:
#             try:
#                 resp = requests.get(OPEN_DEFINITION)
#                 if resp.status_code != requests.codes.ok:
#                     raise Exception("(%s) Cannot get OpenDefinition licenses.", OPEN_DEFINITION)
#                 self.licenses_list = resp.json()
#             except Exception as e:
#                 try:
#                     resp = requests.get(GITHUB)
#                     if resp.status_code != requests.codes.ok:
#                         raise Exception("(%s) Cannot get OpenDefinition licenses.", OPEN_DEFINITION)
#                     self.licenses_list = resp.json()
#                 except Exception as e:
#                     with open(LOCAL_FILE, 'r') as f:
#                         self.licenses_list = json.load(f)
#             LicensesOpennessMapping.__licenses_list= self.licenses_list
#         else:
#             self.licenses_list = LicensesOpennessMapping.__licenses_list
# 
#     def map_license(self, title, lid, url):
#         res_id = None
# 
#         # at first check if ID is matching
#         if lid:
#             if lid in ID_MAPPING_TO_OPEN_DEF and ID_MAPPING_TO_OPEN_DEF[lid]:
#                 common_id = ID_MAPPING_TO_OPEN_DEF[lid]
#             else:
#                 common_id = lid
# 
#             if common_id in self.licenses_list:
#                 res_id = common_id
# 
#         # check if title is ID or if title is matching
#         if not res_id and title:
#             if title in TITLE_MAPPING_TO_OPEN_DEF and TITLE_MAPPING_TO_OPEN_DEF[title]:
#                 common_id = TITLE_MAPPING_TO_OPEN_DEF[title]
#             else:
#                 common_id = title
# 
#             if common_id in self.licenses_list:
#                 res_id = common_id
#             else:
#                 for l in self.licenses_list:
#                     if self.licenses_list[l].get('title') == common_id:
#                         res_id = l
#                         break
# 
#         # check if any url is matching
#         if not res_id and url:
#             for l in self.licenses_list:
#                 if self.licenses_list[l].get('url') == url:
#                     res_id = l
#                     break
# 
#         # assign any possible ID if not already found
#         if not res_id:
#             if lid:
#                 res_id = lid
#             else:
#                 res_id = title if title else url
# 
#         # return a tuple (ID, od_conformance)
#         if res_id in self.licenses_list:
#             return res_id, self.licenses_list[res_id].get('od_conformance', 'not found')
#         return res_id, 'not found'
# 
#     def is_open(self, id):
#         return 'approved' == self.get_od_conformance(id)
# 
#     def get_od_conformance(self, id):
#         if id in self.licenses_list:
#             return self.licenses_list[id].get('od_conformance', 'not found')
#         return 'not found'
# 
# Path: odpw/core/dataset_converter.py
# DCAT = Namespace("http://www.w3.org/ns/dcat#")
# 
# DCT = Namespace("http://purl.org/dc/terms/")
# 
# VCARD = Namespace("http://www.w3.org/2006/vcard/ns#")
# 
# FOAF = Namespace("http://xmlns.com/foaf/0.1/")


from rdflib.namespace import RDFS, RDF
from odpw.core.licenses_mapping import LicensesOpennessMapping
from odpw.core.dataset_converter import DCAT, DCT, VCARD, FOAF
    return accessDistribution(dataset, DCT.title)

def getDistributionDescriptions(dataset):
    return accessDistribution(dataset, DCT.description)

def getDistributionCreationDates(dataset):
    return accessDistribution(dataset, DCT.issued)

def getDistributionModificationDates(dataset):
    return accessDistribution(dataset, DCT.modified)

def getDistributionLicenses(dataset):
    return accessDistribution(dataset, DCT.license)

def safe_unicode1(value):
    """ return the unicode representation of obj """
    if value is None:
        return None

    if type(value) == str:
        # Ignore errors even if the string is not proper UTF-8 or has
        # broken marker bytes.
        # Python built-in function unicode() can do this.
        value = unicode(value, "utf-8", errors="ignore")
    else:
        # Assume the value object has proper __unicode__() method
        value = unicode(value)
    return value

def getDistributionLicenseTriples(dataset):

# Path: odpw/core/licenses_mapping.py
# class LicensesOpennessMapping:
# 
#     __licenses_list=None
# 
#     def __init__(self):
#         if not LicensesOpennessMapping.__licenses_list:
#             try:
#                 resp = requests.get(OPEN_DEFINITION)
#                 if resp.status_code != requests.codes.ok:
#                     raise Exception("(%s) Cannot get OpenDefinition licenses.", OPEN_DEFINITION)
#                 self.licenses_list = resp.json()
#             except Exception as e:
#                 try:
#                     resp = requests.get(GITHUB)
#                     if resp.status_code != requests.codes.ok:
#                         raise Exception("(%s) Cannot get OpenDefinition licenses.", OPEN_DEFINITION)
#                     self.licenses_list = resp.json()
#                 except Exception as e:
#                     with open(LOCAL_FILE, 'r') as f:
#                         self.licenses_list = json.load(f)
#             LicensesOpennessMapping.__licenses_list= self.licenses_list
#         else:
#             self.licenses_list = LicensesOpennessMapping.__licenses_list
# 
#     def map_license(self, title, lid, url):
#         res_id = None
# 
#         # at first check if ID is matching
#         if lid:
#             if lid in ID_MAPPING_TO_OPEN_DEF and ID_MAPPING_TO_OPEN_DEF[lid]:
#                 common_id = ID_MAPPING_TO_OPEN_DEF[lid]
#             else:
#                 common_id = lid
# 
#             if common_id in self.licenses_list:
#                 res_id = common_id
# 
#         # check if title is ID or if title is matching
#         if not res_id and title:
#             if title in TITLE_MAPPING_TO_OPEN_DEF and TITLE_MAPPING_TO_OPEN_DEF[title]:
#                 common_id = TITLE_MAPPING_TO_OPEN_DEF[title]
#             else:
#                 common_id = title
# 
#             if common_id in self.licenses_list:
#                 res_id = common_id
#             else:
#                 for l in self.licenses_list:
#                     if self.licenses_list[l].get('title') == common_id:
#                         res_id = l
#                         break
# 
#         # check if any url is matching
#         if not res_id and url:
#             for l in self.licenses_list:
#                 if self.licenses_list[l].get('url') == url:
#                     res_id = l
#                     break
# 
#         # assign any possible ID if not already found
#         if not res_id:
#             if lid:
#                 res_id = lid
#             else:
#                 res_id = title if title else url
# 
#         # return a tuple (ID, od_conformance)
#         if res_id in self.licenses_list:
#             return res_id, self.licenses_list[res_id].get('od_conformance', 'not found')
#         return res_id, 'not found'
# 
#     def is_open(self, id):
#         return 'approved' == self.get_od_conformance(id)
# 
#     def get_od_conformance(self, id):
#         if id in self.licenses_list:
#             return self.licenses_list[id].get('od_conformance', 'not found')
#         return 'not found'
# 
# Path: odpw/core/dataset_converter.py
# DCAT = Namespace("http://www.w3.org/ns/dcat#")
# 
# DCT = Namespace("http://purl.org/dc/terms/")
# 
# VCARD = Namespace("http://www.w3.org/2006/vcard/ns#")
# 
# FOAF = Namespace("http://xmlns.com/foaf/0.1/")


# Path: odpw/core/dcat_access.py
from rdflib.namespace import RDFS, RDF
from odpw.core.licenses_mapping import LicensesOpennessMapping
from odpw.core.dataset_converter import DCAT, DCT, VCARD, FOAF

    return accessDistribution(dataset, DCT.title)

def getDistributionDescriptions(dataset):
    return accessDistribution(dataset, DCT.description)

def getDistributionCreationDates(dataset):
    return accessDistribution(dataset, DCT.issued)

def getDistributionModificationDates(dataset):
    return accessDistribution(dataset, DCT.modified)

def getDistributionLicenses(dataset):
    return accessDistribution(dataset, DCT.license)

def safe_unicode1(value):
    """ return the unicode representation of obj """
    if value is None:
        return None

    if type(value) == str:
        # Ignore errors even if the string is not proper UTF-8 or has
        # broken marker bytes.
        # Python built-in function unicode() can do this.
        value = unicode(value, "utf-8", errors="ignore")
    else:
        # Assume the value object has proper __unicode__() method
        value = unicode(value)
    return value

def getDistributionLicenseTriples(dataset):

    values = accessDistribution(dataset, DCT.license)