<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_site(sample, convention, Z):
 """ parse the site name from the sample name using the specified convention """

    convention = str(convention)
    site = sample  # default is that site = sample
#
#
# Sample is final letter on site designation eg:  TG001a (used by SIO lab
# in San Diego)
    if convention == "1":
        return sample[:-1]  # peel off terminal character
#
# Site-Sample format eg:  BG94-1  (used by PGL lab in Beijing)
#
    if convention == "2":
        parts = sample.strip('-').split('-')
        return parts[0]
#
# Sample is XXXX.YY where XXX is site and YY is sample
#
    if convention == "3":
        parts = sample.split('.')
        return parts[0]
#
# Sample is XXXXYYY where XXX is site desgnation and YYY is Z long integer
#
    if convention == "4":
        k = int(Z) - 1
        return sample[0:-k]  # peel off Z characters from site

    if convention == "5":  # sample == site
        return sample

    if convention == "6":  # should be names in orient.txt
        print("-W- Finding names in orient.txt is not currently supported")

    if convention == "7":  # peel off Z characters for site
        k = int(Z)
        return sample[0:k]

    if convention == "8":  # peel off Z characters for site
        return ""

    if convention == "9":  # peel off Z characters for site
        return sample

    print("Error in site parsing routine")
    return