Browse Source

formatēšana

Ivars 8 years ago
parent
commit
906b41a432

+ 100
- 0
.vscode/.ropeproject/config.py View File

@@ -0,0 +1,100 @@
1
+# The default ``config.py``
2
+# flake8: noqa
3
+
4
+
5
+def set_prefs(prefs):
6
+    """This function is called before opening the project"""
7
+
8
+    # Specify which files and folders to ignore in the project.
9
+    # Changes to ignored resources are not added to the history and
10
+    # VCSs.  Also they are not returned in `Project.get_files()`.
11
+    # Note that ``?`` and ``*`` match all characters but slashes.
12
+    # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
13
+    # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
14
+    # '.svn': matches 'pkg/.svn' and all of its children
15
+    # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
16
+    # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
17
+    prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
18
+                                  '.hg', '.svn', '_svn', '.git', '.tox']
19
+
20
+    # Specifies which files should be considered python files.  It is
21
+    # useful when you have scripts inside your project.  Only files
22
+    # ending with ``.py`` are considered to be python files by
23
+    # default.
24
+    #prefs['python_files'] = ['*.py']
25
+
26
+    # Custom source folders:  By default rope searches the project
27
+    # for finding source folders (folders that should be searched
28
+    # for finding modules).  You can add paths to that list.  Note
29
+    # that rope guesses project source folders correctly most of the
30
+    # time; use this if you have any problems.
31
+    # The folders should be relative to project root and use '/' for
32
+    # separating folders regardless of the platform rope is running on.
33
+    # 'src/my_source_folder' for instance.
34
+    #prefs.add('source_folders', 'src')
35
+
36
+    # You can extend python path for looking up modules
37
+    #prefs.add('python_path', '~/python/')
38
+
39
+    # Should rope save object information or not.
40
+    prefs['save_objectdb'] = True
41
+    prefs['compress_objectdb'] = False
42
+
43
+    # If `True`, rope analyzes each module when it is being saved.
44
+    prefs['automatic_soa'] = True
45
+    # The depth of calls to follow in static object analysis
46
+    prefs['soa_followed_calls'] = 0
47
+
48
+    # If `False` when running modules or unit tests "dynamic object
49
+    # analysis" is turned off.  This makes them much faster.
50
+    prefs['perform_doa'] = True
51
+
52
+    # Rope can check the validity of its object DB when running.
53
+    prefs['validate_objectdb'] = True
54
+
55
+    # How many undos to hold?
56
+    prefs['max_history_items'] = 32
57
+
58
+    # Shows whether to save history across sessions.
59
+    prefs['save_history'] = True
60
+    prefs['compress_history'] = False
61
+
62
+    # Set the number spaces used for indenting.  According to
63
+    # :PEP:`8`, it is best to use 4 spaces.  Since most of rope's
64
+    # unit-tests use 4 spaces it is more reliable, too.
65
+    prefs['indent_size'] = 4
66
+
67
+    # Builtin and c-extension modules that are allowed to be imported
68
+    # and inspected by rope.
69
+    prefs['extension_modules'] = []
70
+
71
+    # Add all standard c-extensions to extension_modules list.
72
+    prefs['import_dynload_stdmods'] = True
73
+
74
+    # If `True` modules with syntax errors are considered to be empty.
75
+    # The default value is `False`; When `False` syntax errors raise
76
+    # `rope.base.exceptions.ModuleSyntaxError` exception.
77
+    prefs['ignore_syntax_errors'] = False
78
+
79
+    # If `True`, rope ignores unresolvable imports.  Otherwise, they
80
+    # appear in the importing namespace.
81
+    prefs['ignore_bad_imports'] = False
82
+
83
+    # If `True`, rope will insert new module imports as
84
+    # `from <package> import <module>` by default.
85
+    prefs['prefer_module_from_imports'] = False
86
+
87
+    # If `True`, rope will transform a comma list of imports into
88
+    # multiple separate import statements when organizing
89
+    # imports.
90
+    prefs['split_imports'] = False
91
+
92
+    # If `True`, rope will sort imports alphabetically by module name
93
+    # instead of alphabetically by import statement, with from imports
94
+    # after normal imports.
95
+    prefs['sort_imports_alphabetically'] = False
96
+
97
+
98
+def project_opened(project):
99
+    """This function is called after opening the project"""
100
+    # Do whatever you like here!

+ 168
- 0
.vscode/launch.json View File

@@ -0,0 +1,168 @@
1
+{
2
+    "version": "0.2.0",
3
+    "configurations": [{
4
+            "name": "Python",
5
+            "type": "python",
6
+            "request": "launch",
7
+            "stopOnEntry": true,
8
+            "pythonPath": "${config.python.pythonPath}",
9
+            "program": "${file}",
10
+            "cwd": "${workspaceRoot}",
11
+            "console": "integratedTerminal",
12
+            "debugOptions": [
13
+                "WaitOnAbnormalExit",
14
+                "WaitOnNormalExit",
15
+                "RedirectOutput"
16
+            ]
17
+        },
18
+        {
19
+            "name": "PySpark",
20
+            "type": "python",
21
+            "request": "launch",
22
+            "stopOnEntry": true,
23
+            "osx": {
24
+                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
25
+            },
26
+            "windows": {
27
+                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd"
28
+            },
29
+            "linux": {
30
+                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
31
+            },
32
+            "program": "${file}",
33
+            "cwd": "${workspaceRoot}",
34
+            "debugOptions": [
35
+                "WaitOnAbnormalExit",
36
+                "WaitOnNormalExit",
37
+                "RedirectOutput"
38
+            ]
39
+        },
40
+        {
41
+            "name": "Python Module",
42
+            "type": "python",
43
+            "request": "launch",
44
+            "stopOnEntry": true,
45
+            "pythonPath": "${config.python.pythonPath}",
46
+            "module": "module.name",
47
+            "cwd": "${workspaceRoot}",
48
+            "debugOptions": [
49
+                "WaitOnAbnormalExit",
50
+                "WaitOnNormalExit",
51
+                "RedirectOutput"
52
+            ]
53
+        },
54
+        {
55
+            "name": "Integrated Terminal/Console",
56
+            "type": "python",
57
+            "request": "launch",
58
+            "stopOnEntry": true,
59
+            "pythonPath": "${config.python.pythonPath}",
60
+            "program": "${file}",
61
+            "cwd": "null",
62
+            "console": "integratedTerminal",
63
+            "debugOptions": [
64
+                "WaitOnAbnormalExit",
65
+                "WaitOnNormalExit"
66
+            ]
67
+        },
68
+        {
69
+            "name": "External Terminal/Console",
70
+            "type": "python",
71
+            "request": "launch",
72
+            "stopOnEntry": true,
73
+            "pythonPath": "${config.python.pythonPath}",
74
+            "program": "${file}",
75
+            "cwd": "null",
76
+            "console": "externalTerminal",
77
+            "debugOptions": [
78
+                "WaitOnAbnormalExit",
79
+                "WaitOnNormalExit"
80
+            ]
81
+        },
82
+        {
83
+            "name": "Django",
84
+            "type": "python",
85
+            "request": "launch",
86
+            "stopOnEntry": true,
87
+            "pythonPath": "${config.python.pythonPath}",
88
+            "program": "${workspaceRoot}/manage.py",
89
+            "cwd": "${workspaceRoot}",
90
+            "args": [
91
+                "runserver",
92
+                "--noreload"
93
+            ],
94
+            "debugOptions": [
95
+                "WaitOnAbnormalExit",
96
+                "WaitOnNormalExit",
97
+                "RedirectOutput",
98
+                "DjangoDebugging"
99
+            ]
100
+        },
101
+        {
102
+            "name": "Flask",
103
+            "type": "python",
104
+            "request": "launch",
105
+            "stopOnEntry": false,
106
+            "pythonPath": "${config.python.pythonPath}",
107
+            "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
108
+            "cwd": "${workspaceRoot}",
109
+            "env": {
110
+                "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
111
+            },
112
+            "args": [
113
+                "run",
114
+                "--no-debugger",
115
+                "--no-reload"
116
+            ],
117
+            "debugOptions": [
118
+                "WaitOnAbnormalExit",
119
+                "WaitOnNormalExit",
120
+                "RedirectOutput"
121
+            ]
122
+        },
123
+        {
124
+            "name": "Flask (old)",
125
+            "type": "python",
126
+            "request": "launch",
127
+            "stopOnEntry": false,
128
+            "pythonPath": "${config.python.pythonPath}",
129
+            "program": "${workspaceRoot}/run.py",
130
+            "cwd": "${workspaceRoot}",
131
+            "args": [],
132
+            "debugOptions": [
133
+                "WaitOnAbnormalExit",
134
+                "WaitOnNormalExit",
135
+                "RedirectOutput"
136
+            ]
137
+        },
138
+        {
139
+            "name": "Watson",
140
+            "type": "python",
141
+            "request": "launch",
142
+            "stopOnEntry": true,
143
+            "pythonPath": "${config.python.pythonPath}",
144
+            "program": "${workspaceRoot}/console.py",
145
+            "cwd": "${workspaceRoot}",
146
+            "args": [
147
+                "dev",
148
+                "runserver",
149
+                "--noreload=True"
150
+            ],
151
+            "debugOptions": [
152
+                "WaitOnAbnormalExit",
153
+                "WaitOnNormalExit",
154
+                "RedirectOutput"
155
+            ]
156
+        },
157
+        {
158
+            "name": "Attach (Remote Debug)",
159
+            "type": "python",
160
+            "request": "attach",
161
+            "localRoot": "${workspaceRoot}",
162
+            "remoteRoot": "${workspaceRoot}",
163
+            "port": 3000,
164
+            "secret": "my_secret",
165
+            "host": "localhost"
166
+        }
167
+    ]
168
+}

+ 5
- 6
ContentSources.py View File

@@ -7,25 +7,24 @@
7 7
 #
8 8
 
9 9
 import sys,os,re
10
-import urllib2
11 10
 sys.path.insert(0,os.path.dirname(os.path.abspath(__file__)))
12 11
 from  sources.SourceBase import stream_type
13 12
 import util
14 13
 
15 14
 
16
-stream0 = {'name': '', 'url': '', 'quality': '???', 'surl': '', 'subs': '', 'headers': {},"desc":"","img":"","lang":"","type":""}
15
+stream0 = {'name': '', 'url': '', 'quality': '???', 'surl': '', 'subs': '', 'headers': {}, "desc":"", "img":"", "lang": "", "type": ""}
17 16
 
18 17
 class ContentSources(object):
19 18
     """Wrapper for content sources plugin"""
20 19
 
21 20
     #----------------------------------------------------------------------
22
-    def __init__(self,plugin_path):
21
+    def __init__(self, plugin_path):
23 22
         self.plugins = {}
24
-        self.error_content = [("..atpakaļ","back",None,"Kļūda, atgriezties atpakaļ")]
23
+        self.error_content = [("..atpakaļ", "back", None, "Kļūda, atgriezties atpakaļ")]
25 24
         sys.path.insert(0, plugin_path)
26 25
         for f in os.listdir(plugin_path):
27 26
             fname, ext = os.path.splitext(f)
28
-            if fname == "__init__":continue
27
+            if fname == "__init__": continue
29 28
             if ext == '.py':
30 29
                 mod = __import__(fname)
31 30
                 reload(mod)
@@ -164,7 +163,7 @@ if __name__ == "__main__":
164 163
         cur2 = content[n-1]
165 164
 
166 165
         data0 = cur2[1].split("::")[1] if "::" in cur2[1] else cur2[1]
167
-        if (not data0):
166
+        if not data0:
168 167
             pass
169 168
 
170 169
         elif cur2[1] == "back":

+ 22
- 22
imake.bat View File

@@ -2,7 +2,7 @@
2 2
 :=== Parameters ===
3 3
 
4 4
 if ()==(%1%) (
5
-    set ver=0.5o
5
+    set ver=0.5p
6 6
 	rem echo Please provide version
7 7
 	rem pause
8 8
 	rem GOTO:EOF
@@ -24,7 +24,7 @@ set AR=\MinGW\bin\ar.exe
24 24
 set TAR=\MinGW\msys\1.0\bin\tar.exe
25 25
 
26 26
 :=== data files ===
27
-if exist %ipk_dir% rm -r -f %ipk_dir% 
27
+if exist %ipk_dir% rm -r -f %ipk_dir%
28 28
 mkdir %ipk_dir%
29 29
 for %%f in (
30 30
 readme.md
@@ -43,26 +43,26 @@ streamproxy.py
43 43
 offline.mp4
44 44
 demjson.py
45 45
 locale\*.*
46
-sources\__init__.py          
47
-sources\SourceBase.py        
48
-sources\cinemalive.py        
49
-sources\config.py            
50
-sources\euronews.py          
51
-sources\filmix.py            
52
-sources\filmon.py            
53
-sources\iplayer.py           
46
+sources\__init__.py
47
+sources\SourceBase.py
48
+sources\cinemalive.py
49
+sources\config.py
50
+sources\euronews.py
51
+sources\filmix.py
52
+sources\filmon.py
53
+sources\iplayer.py
54 54
 sources\kinofilmnet.py
55
-sources\movieplace.py       
56
-sources\ltc.py               
57
-sources\mtgplay.py           
58
-sources\play24.py            
59
-sources\replay.py            
60
-sources\serialguru.py        
61
-sources\tvdom.py             
62
-sources\ustvnow.py           
63
-sources\viaplay.py           
64
-sources\YouTubeVideoUrl.py   
65
-sources\jsinterp.py          
55
+sources\movieplace.py
56
+sources\ltc.py
57
+sources\mtgplay.py
58
+sources\play24.py
59
+sources\replay.py
60
+sources\serialguru.py
61
+sources\tvdom.py
62
+sources\ustvnow.py
63
+sources\viaplay.py
64
+sources\YouTubeVideoUrl.py
65
+sources\jsinterp.py
66 66
 sources\swfinterp.py
67 67
 sources\streams.cfg
68 68
 resolvers\__init__.py
@@ -91,7 +91,7 @@ echo Section:
91 91
 echo Priority: optional
92 92
 echo Maintainer: ivars777@gmail.com
93 93
 echo Homepage:
94
-echo Depends: python-json,python-twisted-web,python-simplejson,python-html,python-zlib,python-requests 
94
+echo Depends: python-json,python-twisted-web,python-simplejson,python-html,python-zlib,python-requests
95 95
 echo Source:
96 96
 ) >%ipk_dir%CONTROL\control
97 97
 dos2unix %ipk_dir%CONTROL\control

+ 2
- 2
ipkg/CONTROL/control View File

@@ -1,4 +1,4 @@
1
-Version: 0.5o
1
+Version: 0.5p
2 2
 Package: enigma2-plugin-extensions-playstream
3 3
 Description: Play online streams from various sources, mostly Latvian
4 4
 Architecture: all
@@ -6,5 +6,5 @@ Section:
6 6
 Priority: optional
7 7
 Maintainer: ivars777@gmail.com
8 8
 Homepage:
9
-Depends: python-json,python-twisted-web,python-simplejson,python-html,python-zlib,python-requests 
9
+Depends: python-json,python-twisted-web,python-simplejson,python-html,python-zlib,python-requests
10 10
 Source:

BIN
ipkg/control.tar.gz View File


BIN
ipkg/data.tar.gz View File


+ 11
- 9
ipkg/data/usr/lib/enigma2/python/Plugins/Extensions/PlayStream/ContentSources.py View File

@@ -11,7 +11,9 @@ import urllib2
11 11
 sys.path.insert(0,os.path.dirname(os.path.abspath(__file__)))
12 12
 from  sources.SourceBase import stream_type
13 13
 import util
14
-stream0 = {'name': '', 'url': '', 'quality': '???', 'surl': '', 'subs': '', 'headers': {},"desc":"","img":"","lang":"","type":""}                   
14
+
15
+
16
+stream0 = {'name': '', 'url': '', 'quality': '???', 'surl': '', 'subs': '', 'headers': {},"desc":"","img":"","lang":"","type":""}
15 17
 
16 18
 class ContentSources(object):
17 19
     """Wrapper for content sources plugin"""
@@ -46,12 +48,12 @@ class ContentSources(object):
46 48
                 cfg.add_item("home",(title,"%s::home"%pl,img,desc))
47 49
                 cfg.write_streams()
48 50
 
49
-    def get_content(self,data):        
51
+    def get_content(self,data):
50 52
         source = data.split("::")[0]
51 53
         if source in self.plugins:
52 54
             content = self.plugins[source].get_content(data)
53 55
             if content:
54
-                if isinstance(content,list):      
56
+                if isinstance(content,list):
55 57
                     for i,item in enumerate(content):
56 58
                         item2=[]
57 59
                         for el in item:
@@ -75,7 +77,7 @@ class ContentSources(object):
75 77
     def get_streams(self,data):
76 78
         if stream_type(data):
77 79
             if "::" in data:
78
-                data = data.split("::")[1]                    
80
+                data = data.split("::")[1]
79 81
             content = self.get_content(data)
80 82
             stream = stream0.copy()
81 83
             stream["name"] = data
@@ -93,7 +95,7 @@ class ContentSources(object):
93 95
             for s in streams:
94 96
                 for k in s:
95 97
                     if isinstance(s[k],unicode):
96
-                        s[k] = s[k].encode("utf8")            
98
+                        s[k] = s[k].encode("utf8")
97 99
             return streams
98 100
         else:
99 101
             return []
@@ -149,7 +151,7 @@ if __name__ == "__main__":
149 151
 
150 152
         while True:
151 153
             a = raw_input("Enter numeber, q for exit: ")
152
-            if a in ("q","Q","x","X"): 
154
+            if a in ("q","Q","x","X"):
153 155
                 exit_loop = True
154 156
                 print "Exiting"
155 157
                 break
@@ -158,7 +160,7 @@ if __name__ == "__main__":
158 160
                 break
159 161
             except:
160 162
                 print "Not number!"
161
-        if exit_loop: break 
163
+        if exit_loop: break
162 164
         cur2 = content[n-1]
163 165
 
164 166
         data0 = cur2[1].split("::")[1] if "::" in cur2[1] else cur2[1]
@@ -166,7 +168,7 @@ if __name__ == "__main__":
166 168
             pass
167 169
 
168 170
         elif cur2[1] == "back":
169
-            cur = history.pop()  
171
+            cur = history.pop()
170 172
         elif sources.is_video(cur2[1]):
171 173
             if sources.stream_type(cur2[1]):
172 174
                 stream = stream0.copy()
@@ -186,7 +188,7 @@ if __name__ == "__main__":
186 188
         else:
187 189
             if "{0}" in cur2[1]:
188 190
                 a = raw_input("Enter value:")
189
-                cur2 = (cur2[0],cur2[1].format(a),cur2[2],cur2[3])           
191
+                cur2 = (cur2[0],cur2[1].format(a),cur2[2],cur2[3])
190 192
             history.append(cur)
191 193
             cur = cur2
192 194
         content = sources.get_content(cur[1])

+ 1
- 1
resolvers/hqqresolver.py View File

@@ -21,7 +21,7 @@ try:
21 21
     import util
22 22
 except:
23 23
     pp = os.path.dirname(os.path.abspath(__file__))
24
-    sys.path.insert(0,os.sep.join(pp.split(os.sep)[:-1]))
24
+    sys.path.insert(0, os.sep.join(pp.split(os.sep)[:-1]))
25 25
     import util
26 26
 import requests
27 27
 

BIN
resolvers/hqqresolver.pyc View File


+ 4
- 4
sources/movieplace.py View File

@@ -23,7 +23,7 @@ h = HTMLParser.HTMLParser()
23 23
 
24 24
 class Source(SourceBase):
25 25
 
26
-    def __init__(self,country=""):
26
+    def __init__(self, country=""):
27 27
         self.name = "movieplace"
28 28
         self.title = "MoviePlace.lv"
29 29
         self.img = "http://movieplace.lv/images/logo.png"
@@ -44,8 +44,8 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
44 44
     ######### Entry point ########
45 45
     def get_content(self, data):
46 46
         print "[movieplace] get_content:", data
47
-        source,data,path,plist,clist,params,qs = self.parse_data(data)
48
-        content=[]
47
+        source, data, path, plist, clist, params, qs = self.parse_data(data)
48
+        content = []
49 49
         content.append(("..return", "back","","Return back"))
50 50
 
51 51
         if clist=="home":
@@ -93,7 +93,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
93 93
             else:
94 94
                 r = self.call(data)
95 95
             #r = r.decode("cp1251").encode("utf8")
96
-            if clist=="load":
96
+            if clist == "load":
97 97
                 result = re.findall(r' <a href="/([^"]+)" alt="([^"]+)"><img src="/([^"]+)" title="([^"]+)">.+?<div class="years">([^<]+)</div>\s+<div class="country">([^<]+)</div>', r, re.DOTALL)
98 98
             else:
99 99
                 result = re.findall(r' <a href="/([^"]+)" alt="([^"]+)"><img src="/([^"]+)" title="[^"]+">.+?<span>([^<]+)</span>\s*<div class="country">([^<]+)</div>', r, re.IGNORECASE | re.DOTALL)

+ 13
- 1
util.py View File

@@ -248,7 +248,19 @@ def ttaf2srt(s):
248 248
 
249 249
 
250 250
 def item():
251
-    stream0 = {'name': '', 'url': '', 'quality': '???', 'surl': '', 'subs': '', 'headers': {},"desc":"","img":"","lang":"","type":"","order":0}
251
+    stream0 = {
252
+        'name': '',
253
+        'url': '',
254
+        'quality': '?',
255
+        'surl': '',
256
+        'subs': [],
257
+        'headers': {},
258
+        "desc":"","img":"",
259
+        "lang":"",
260
+        "type":"",
261
+        "resolver":"",
262
+        "order":0
263
+        }
252 264
     return stream0
253 265
 
254 266
 class _StringCookieJar(cookielib.LWPCookieJar):

BIN
util.pyc View File