Exemplo n.º 1
0
def get_coach_data(filepath):
    try:
        with open(filepath) as f:
            data = f.readline().strip().split(',')
            return AthleteList(data.pop(0), data.pop(0), data)
    except IOError as err:
        print('File error: ' + str(err))
        return None
Exemplo n.º 2
0
def get_coach_data(filename):
    try:
        with open(filename) as f:
            value = f.readline()
            values = value.strip().split(",")
            return AthleteList(values.pop(0), values.pop(0), values)
    except IOError as ioerror:
        print("File error: " + str(ioerror))
        return None
Exemplo n.º 3
0
def get_coach_data(filename):
    try:
        with open(filename) as f:
            data = f.readline()
        templ = data.strip().split(',')
        return (AthleteList(templ.pop(0), templ.pop(0), templ))
    except IOError as ioerr:
        print('File error:' + str(ioerr))
        return (None)
Exemplo n.º 4
0
def get_coach_data(file_name):
    try:
        with open(file_name) as f:
            data = f.readline()
        file_content = data.strip().split(',')
        return (AthleteList(file_content.pop(0),file_content.pop(0),file_content))
    except IOError as err:
        print('File error ' + str(err))
        return None
Exemplo n.º 5
0
def read_file(file_name):
    try:
        with open(file_name) as data:
            line = data.readline()
            values = line.strip().split(",")
            return AthleteList(values.pop(0), values.pop(0), values)
    except IOError as err:
        print("File Error : " + str(err))
        return None
Exemplo n.º 6
0
def get_coach_data(file_name):
    try:
        with open(file_name) as f:
            data = f.readline().strip().split(',')
        return AthleteList(data.pop(0), data.pop(0),
                           [sanitize(each_data) for each_data in data])
    except IOError as e:
        print('file error: ', str(e))
        return (None)
Exemplo n.º 7
0
def getCoachData(file_name):
    try:
        with open(file_name) as f:
            data = f.readline()
            data_list = data.split(',')
            data_list = [t.strip() for t in data_list]
            return AthleteList(data_list.pop(0), data_list.pop(0), data_list)
    except IOError as ioe:
        print(str(ioe))
        return None
Exemplo n.º 8
0
def get_data(filename):
    try:
        with open(filename) as data:
            data = data.readline()
            data = data.strip().split(',')
            data = {"name": data.pop(0), "dob": data.pop(0), "times": data}
            return AthleteList(data)
    except IOError as ioerr:
        print("IOError: " + ioerr)
        return (None)
Exemplo n.º 9
0
def get_coach_data(filename):
	# Not shown here as it has not changed since the last chapter.
	try:
		with open(filename) as f:
			data=f.readline()
		templ=data.strip().split(',')
		return(AthleteList(templ.pop(0),templ.pop(0),templ))
	except IOError as ioerr:
		print ('File error: ' + str(ioerr))
		return(None)
Exemplo n.º 10
0
def get_coach_data(file_name):
    try:
        with open(file_name) as file:
            data = file.readline()

        templ = data.strip().split(',')
        return (AthleteList(templ.pop(0), templ.pop(0), templ))
    except IOError as err:
        print('Error: ' + str(err))
        return None
Exemplo n.º 11
0
def get_coach_data(filename):
    try:
        with open(filename) as f:
            data = f.readline()
        # 读取数据
        tmp_list = data.strip().split(",")
        # 返回字典数据
        return (AthleteList(tmp_list.pop(0), tmp_list.pop(0), tmp_list))
    except IOError as error:
        print('File error:' + str(error))
    # 返回空数据
    return (None)
Exemplo n.º 12
0
def get_coach_data(filename):
  try:
    with open(filename) as f:
      data = f.readline()
      data = (data.strip().split(','))
      athlete = AthleteList(data.pop(0), data.pop(0), data)
      return athlete

  except IOError as ioerr:
    print('File error: ' + str(ioerr))

  return(None)
Exemplo n.º 13
0
def get_coach_data(filename):
    """
    将指定文件去除不需要的空白符并返回列表。
    参数"filename“,将要转换为列表的文件路径。
    """
    try:
        with open(filename) as fl:
            data = fl.readline().strip().split(',')

        return AthleteList(data.pop(0), data.pop(0), data)
    except IOError as err:
        print('File Error\n\t' + str(err))
        return None
Exemplo n.º 14
0
def get_coach_data(filename):
    try:
        with open(filename) as f:
            data = f.readline()
            data = data.strip().split(',')
            name = data.pop(0)
            dob = data.pop(0)
            times = data
            athlete = AthleteList(name, dob, times)
        return athlete

    except IOError as ioerr:
        print('File error(get_coach_data): ' + str(ioerr))
        return (None)
Exemplo n.º 15
0
# addr = os.environ['REMOTE_ADDR']
# host = os.environ['REMOTE_HOST']
# method = os.environ['REQUEST_METHOD']
# cur_time = time.asctime(time.localtime())
# print(host+', '+addr+', '+cur_time+': '+method+': ', end='',file=sys.stderr)

form = cgi.FieldStorage()
# for each_form_item in form.keys():
#     print(each_form_item+' -> '+form[each_form_item].value, end=' ',file=sys.stderr)
# print(file=sys.stderr)

the_id = form['Athlete'].value
the_time = form['Time'].value

# unify the format
the_time = AthleteList.sanitize(the_time)

athletemodel.add_timing_by_id(the_id, the_time)

# connection = sqlite3.connect('coachdata.sqlite')
# cursor = connection.cursor()
# athlete = athletemodel.get_athlete_from_id(the_id)
# remember we have changed data format in athletemodel


# if float(the_time) in athlete['data']:
#     print('Already exist', file=sys.stderr)
#     pass
# else:
#     cursor.execute("INSERT INTO timing_data (athlete_id, value) VALUES (?,?)",(the_id, the_time))
#     connection.commit()
Exemplo n.º 16
0
def crt_athlete(data):
    a = AthleteList(data.pop(0), data.pop(0), sanitize(data))
    return a
Exemplo n.º 17
0
from athletelist import AthleteList


def getCoachData(file_name):
    try:
        with open(file_name) as f:
            data = f.readline()
            data_list = data.split(',')
            data_list = [t.strip() for t in data_list]
            return AthleteList(data_list.pop(0), data_list.pop(0), data_list)
    except IOError as ioe:
        print(str(ioe))
        return None


vera = AthleteList('Vera Vi')
vera.append('1.31')
print(vera.top3())
vera.extend(['2.22', '1-21', '2:22'])
print(vera.top3())
sarah = AthleteList()
sarah = getCoachData('sarah2.txt')
print(sarah.name + "\t" + sarah.dob + "\t" + str(sarah))