# Path: ethronsoft/gcspypi/utilities/version.py
# def complete_version(v):
#     """adds missing '0' to a version that has less than 3 components
#     
#     Arguments:
#         v {str} -- The version to update
#     
#     Returns:
#         str -- The modified version
#     """
# 
#     tokens = [x for x in v.split(".") if x.strip()]
#     if len(tokens) > 3:
#         raise InvalidParameter("Invalid Version")
#     for i in range(3 - len(tokens)):
#         tokens.append("0")
#     return ".".join(tokens)
# 
# Path: ethronsoft/gcspypi/exceptions/boundary_errors.py
# class InvalidParameter(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/exceptions/state_errors.py
# class InvalidState(Exception):
#     pass


from ethronsoft.gcspypi.utilities.version import complete_version
from ethronsoft.gcspypi.exceptions import InvalidState, InvalidParameter
import os
#             else:  # minor equal
#                 if self.patch > o.patch:
#                     return False
#                 elif self.patch < o.patch:
#                     return True
#                 else:  # patch equal
#                     return False

#     def __cmp__(self, o):
#         if self < o:
#             return -1
#         elif self > o:
#             return 1
#         else:
#             return 0


class Package(object):

    def __init__(self, name, version="", requirements=set([]), type=""):
        self.name = name.replace("_", "-")
        self.version = complete_version(version) if version else None
        self.requirements = set([])
        self.type = type
        for r in requirements:
            self.requirements.add(r.replace("_","-"))

    @staticmethod
    def repo_name(pkg, filename):
        if not pkg.version:

# Path: ethronsoft/gcspypi/utilities/version.py
# def complete_version(v):
#     """adds missing '0' to a version that has less than 3 components
#     
#     Arguments:
#         v {str} -- The version to update
#     
#     Returns:
#         str -- The modified version
#     """
# 
#     tokens = [x for x in v.split(".") if x.strip()]
#     if len(tokens) > 3:
#         raise InvalidParameter("Invalid Version")
#     for i in range(3 - len(tokens)):
#         tokens.append("0")
#     return ".".join(tokens)
# 
# Path: ethronsoft/gcspypi/exceptions/boundary_errors.py
# class InvalidParameter(Exception):
#     pass
# 
# Path: ethronsoft/gcspypi/exceptions/state_errors.py
# class InvalidState(Exception):
#     pass


# Path: ethronsoft/gcspypi/package/package.py
from ethronsoft.gcspypi.utilities.version import complete_version
from ethronsoft.gcspypi.exceptions import InvalidState, InvalidParameter
import os

#             else:  # minor equal
#                 if self.patch > o.patch:
#                     return False
#                 elif self.patch < o.patch:
#                     return True
#                 else:  # patch equal
#                     return False

#     def __cmp__(self, o):
#         if self < o:
#             return -1
#         elif self > o:
#             return 1
#         else:
#             return 0


class Package(object):

    def __init__(self, name, version="", requirements=set([]), type=""):
        self.name = name.replace("_", "-")
        self.version = complete_version(version) if version else None
        self.requirements = set([])
        self.type = type
        for r in requirements:
            self.requirements.add(r.replace("_","-"))

    @staticmethod
    def repo_name(pkg, filename):
        if not pkg.version:

            raise InvalidState("cannot formulate package repository-name for a package without version")