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.

69 lines
1.3 KiB

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. if file_exist(filename):
  23. os.remove(filename)
  24. def get_path_seperator():
  25. if os.name == 'nt':
  26. return '\\'
  27. else:
  28. return '/'
  29. def fix_path(path):
  30. if path != '':
  31. if path[-1:] != get_path_seperator():
  32. path += get_path_seperator()
  33. return path
  34. def get_HOME():
  35. return os.path.expanduser("~")
  36. def add_PATH(path):
  37. os.environ["PATH"] += os.pathsep + path
  38. def get_abs_path(path):
  39. sep = get_path_seperator()
  40. path_list = path.split(sep)
  41. for i in range(len(path_list)):
  42. if path_list[i] == '~':
  43. path_list[i] = get_HOME()
  44. path = sep.join(path_list)
  45. return path
  46. def file_exist(filename):
  47. return os.path.exists(filename)
  48. def get_os_type():
  49. return os.name
  50. def makedir(path):
  51. os.makedirs(path)