File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 11import re
22import sys
3- from typing import Tuple
43
54from collections import namedtuple
65from pprint import pprint
1312app = typer .Typer ()
1413
1514
16- def setup (path : str , quiet : bool ) -> Tuple [ str , PAPath ] :
15+ def setup (path : str , quiet : bool ) -> PAPath :
1716 logger = get_logger (set_info = True )
1817 if quiet :
1918 logger .disabled = True
@@ -44,7 +43,7 @@ def get(
4443 if contents is None :
4544 sys .exit (1 )
4645
47- if raw or type (contents ) == str :
46+ if raw or isinstance (contents , str ) :
4847 {dict : pprint , str : print }[type (contents )](contents )
4948 sys .exit ()
5049
Original file line number Diff line number Diff line change @@ -47,10 +47,10 @@ def __repr__(self):
4747 def _make_sharing_url (self , path ):
4848 return urljoin (self .api .base_url .split ("api" )[0 ], path )
4949
50- def _standarize_path (self , path ):
50+ @staticmethod
51+ def _standarize_path (path ):
5152 return path .replace ("~" , f"/home/{ getpass .getuser ()} " ) if path .startswith ("~" ) else path
5253
53-
5454 @property
5555 def url (self ):
5656 """Returns url to PythonAnywhere for `self.path`. Does not
@@ -81,7 +81,7 @@ def contents(self):
8181
8282 try :
8383 content = self .api .path_get (self .path )
84- return content if type (content ) == dict else content .decode ("utf-8" )
84+ return content if isinstance (content , dict ) else content .decode ("utf-8" )
8585 except Exception as e :
8686 logger .warning (snakesay (str (e )))
8787 return None
Original file line number Diff line number Diff line change 1- from typing import List , Optional , Union
1+ from typing import Optional , Union
2+
3+ from typer import FileBinaryRead
4+
5+ from pythonanywhere .api .files_api import Files
26
3- from typing_extensions import Literal
47
58class PAPath :
9+ path : str = ...
10+ api : Files = ...
611 def __init__ (self , path : str ) -> None : ...
712 def __repr__ (self ) -> str : ...
13+ def _make_sharing_url (self , path : str ) -> str : ...
14+ @staticmethod
15+ def _standarize_path (path : str ) -> str : ...
16+ @property
17+ def url (self ) -> str : ...
18+ @property
819 def contents (self ) -> Optional [Union [dict , str ]]: ...
20+ @property
921 def tree (self ) -> Optional [list ]: ...
1022 def delete (self ) -> bool : ...
11- def upload (self , content : bytes ) -> bool : ...
23+ def upload (self , content : FileBinaryRead ) -> bool : ...
1224 def get_sharing_url (self ) -> str : ...
1325 def share (self ) -> str : ...
1426 def unshare (self ) -> bool : ...
You can’t perform that action at this time.
0 commit comments