You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #! /usr/bin/env python
  2. import os
  3. import sys
  4. def remove_spaces(array):
  5. return [x for x in array if x != '']
  6. def string_to_array(string, char=' '):
  7. return string.split(char)
  8. def get_encoding():
  9. if sys.version_info >= (3, 0):
  10. return None
  11. if sys.platform == 'win32':
  12. return sys.getfilesystemencoding()
  13. else:
  14. return None
  15. def encode_list(data_list, encoding):
  16. return [x.encode(encoding, 'ignore') for x in data_list]
  17. def video_is_dash(video):
  18. return "DASH" in video
  19. def have_dash_audio(audio):
  20. return audio != "NO SOUND"
  21. def remove_file(filename):
  22. os.remove(filename)
  23. def get_path_seperator():
  24. return '\\' if os.name == 'nt' else '/'
  25. def fix_path(path):
  26. if path != '':
  27. if path[-1:] != get_path_seperator():
  28. path += get_path_seperator()
  29. return path
  30. def get_HOME():
  31. return os.path.expanduser("~")
  32. def add_PATH(path):
  33. os.environ["PATH"] += os.pathsep + path
  34. def get_abs_path(path):
  35. path_list = path.split(get_path_seperator())
  36. for i in range(len(path_list)):
  37. if path_list[i] == '~':
  38. path_list[i] = get_HOME()
  39. path = get_path_seperator().join(path_list)
  40. return path
  41. def file_exist(filename):
  42. return os.path.exists(filename)
  43. def get_os_type():
  44. return os.name
  45. def get_filesize(path):
  46. return os.path.getsize(path)
  47. def makedir(path):
  48. os.makedirs(path)
  49. def get_icon_path(icon_path, file_path):
  50. path = os.path.abspath(file_path)
  51. path = path.split(get_path_seperator())
  52. for i in range(len(icon_path)):
  53. path[(i+1)*-1] = icon_path[i]
  54. path = get_path_seperator().join(path)
  55. return path
  56. def get_filename(path):
  57. return path.split(get_path_seperator())[-1]