mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Switched out guessit libs for the one CP uses, seems to have less depends
This commit is contained in:
parent
a6cd0f156b
commit
6fea9ddb40
65 changed files with 2034 additions and 7313 deletions
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# GuessIt - A library for guessing information from filenames
|
||||
# Copyright (c) 2013 Nicolas Wack <wackou@gmail.com>
|
||||
# Copyright (c) 2011 Nicolas Wack <wackou@gmail.com>
|
||||
#
|
||||
# GuessIt is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the Lesser GNU General Public License as published by
|
||||
|
@ -18,8 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from guessit import s, u
|
||||
import os.path
|
||||
import zipfile
|
||||
|
@ -45,13 +44,17 @@ def split_path(path):
|
|||
result = []
|
||||
while True:
|
||||
head, tail = os.path.split(path)
|
||||
headlen = len(head)
|
||||
|
||||
if not head and not tail:
|
||||
return result
|
||||
# on Unix systems, the root folder is '/'
|
||||
if head and head == '/'*headlen and tail == '':
|
||||
return ['/'] + result
|
||||
|
||||
if not tail and head == path:
|
||||
# Make sure we won't have an infinite loop.
|
||||
result = [head] + result
|
||||
# on Windows, the root folder is a drive letter (eg: 'C:\') or for shares \\
|
||||
if ((headlen == 3 and head[1:] == ':\\') or (headlen == 2 and head == '\\\\')) and tail == '':
|
||||
return [head] + result
|
||||
|
||||
if head == '' and tail == '':
|
||||
return result
|
||||
|
||||
# we just split a directory ending with '/', so tail is empty
|
||||
|
@ -67,8 +70,8 @@ def split_path(path):
|
|||
def file_in_same_dir(ref_file, desired_file):
|
||||
"""Return the path for a file in the same dir as a given reference file.
|
||||
|
||||
>>> s(file_in_same_dir('~/smewt/smewt.db', 'smewt.settings')) == os.path.normpath('~/smewt/smewt.settings')
|
||||
True
|
||||
>>> s(file_in_same_dir('~/smewt/smewt.db', 'smewt.settings'))
|
||||
'~/smewt/smewt.settings'
|
||||
|
||||
"""
|
||||
return os.path.join(*(split_path(ref_file)[:-1] + [desired_file]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue