4242log = logging .getLogger ("murfey.client" )
4343
4444
45+ def posix_path (path : Path ) -> str :
46+ """
47+ Converts a Windows-style path into a Posix one. Used primarily when running
48+ subproceses in bash terminals, which can only accept Posix paths.
49+ """
50+ path_parts = list (path .parts )
51+ # Check if it's a Windows-style path
52+ if path_parts [0 ].endswith ((":/" , ":\\ " )):
53+ path_parts [0 ] = "/" + path_parts [0 ].strip (":/\\ " ).lower ()
54+ posix_path = "/" .join (path_parts )
55+ return posix_path
56+ return str (path )
57+
58+
4559def read_config () -> configparser .ConfigParser :
4660 config = configparser .ConfigParser ()
4761 try :
@@ -65,6 +79,31 @@ def read_config() -> configparser.ConfigParser:
6579requests .delete = partial (requests .delete , headers = {"Authorization" : f"Bearer { token } " })
6680
6781
82+ def write_config (config : configparser .ConfigParser ):
83+ mcch = os .environ .get ("MURFEY_CLIENT_CONFIG_HOME" )
84+ murfey_client_config_home = Path (mcch ) if mcch else Path .home ()
85+ with open (murfey_client_config_home / ".murfey" , "w" ) as configfile :
86+ config .write (configfile )
87+
88+
89+ def main_loop (
90+ source_watchers : List [murfey .client .watchdir .DirWatcher ],
91+ appearance_time : float ,
92+ transfer_all : bool ,
93+ ):
94+ log .info (
95+ f"Murfey { murfey .__version__ } on Python { '.' .join (map (str , sys .version_info [0 :3 ]))} entering main loop"
96+ )
97+ if appearance_time > 0 :
98+ modification_time : float | None = time .time () - appearance_time * 3600
99+ else :
100+ modification_time = None
101+ while True :
102+ for sw in source_watchers :
103+ sw .scan (modification_time = modification_time , transfer_all = transfer_all )
104+ time .sleep (15 )
105+
106+
68107def _enable_webbrowser_in_cygwin ():
69108 """Helper function to make webbrowser.open() work in CygWin"""
70109 if "cygwin" in platform .system ().lower () and shutil .which ("cygstart" ):
@@ -323,28 +362,3 @@ def run():
323362 )
324363 app .run ()
325364 rich_handler .redirect = False
326-
327-
328- def main_loop (
329- source_watchers : List [murfey .client .watchdir .DirWatcher ],
330- appearance_time : float ,
331- transfer_all : bool ,
332- ):
333- log .info (
334- f"Murfey { murfey .__version__ } on Python { '.' .join (map (str , sys .version_info [0 :3 ]))} entering main loop"
335- )
336- if appearance_time > 0 :
337- modification_time : float | None = time .time () - appearance_time * 3600
338- else :
339- modification_time = None
340- while True :
341- for sw in source_watchers :
342- sw .scan (modification_time = modification_time , transfer_all = transfer_all )
343- time .sleep (15 )
344-
345-
346- def write_config (config : configparser .ConfigParser ):
347- mcch = os .environ .get ("MURFEY_CLIENT_CONFIG_HOME" )
348- murfey_client_config_home = Path (mcch ) if mcch else Path .home ()
349- with open (murfey_client_config_home / ".murfey" , "w" ) as configfile :
350- config .write (configfile )
0 commit comments