from sys import platform as OperatingSystem

Quotes = '"\''

if OperatingSystem == "win32":
    PathSlash = '\\'
else:
    PathSlash = '/'
FileProtocol = "file:" + 2*PathSlash

def ConvertToStandardPathFormat(Path):
    """ Example,
    Input: '"file:///some/path/somefile.extension"
    Output: /some/path/somefile.extension
    """
    Path = Path.strip(Quotes)
    if Path.startswith(FileProtocol):
        Path = Path[len(FileProtocol):]
    return Path

def GetTextAfter(Text, ReadlinesTextFile):
    for Lines in range(len(ReadlinesTextFile)):
        Line = ReadlinesTextFile[Lines].strip('\n')
        if Line.startswith(Text):
            return Line[len(Text):]
    return ''

def SingleQuoteString(String):
    if len(String) > 0:
        if String[0] != '\'' or String[-1] != '\'':
            String = '\'' + String + '\''
    return String

def DoubleQuoteString(String):
    if len(String) > 0:
        if String[0] != '"' or String[-1] != '"':
            String = '"' + String + '"'
    return String

def ListIntoString(List, QuoteItems=0, Seprator=' '):
    if QuoteItems == 2:
        for i in range(len(List)):
            Quoteditem = DoubleQuoteString(List[i])
            List[i] = Quoteditem
    elif QuoteItems == 1:
        for i in range(len(List)):
            Quoteditem = SingleQuoteString(List[i])
            List[i] = Quoteditem
    Stringoflist = (Seprator).join(List)
    return Stringoflist

def StandardVariableName(Variable):
    Variable = Variable.casefold()
    Variable = Variable.replace('_', '').replace(' ', '')
    return Variable
