FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bpython/wdtest.py at cleaning · bpython/bpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
bpython
/
bpython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
252
Star
2.8k
Code
Issues
144
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
bpython
/
wdtest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (42 loc) · 1.48 KB
Breadcrumbs
bpython
/
wdtest.py
Copy path
File metadata and controls
49 lines (42 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import
time
import
os
from
collections
import
defaultdict
from
bpython
import
importcompletion
from
watchdog
.
observers
import
Observer
from
watchdog
.
events
import
FileSystemEventHandler
class
ModuleChangedEventHandler
(
FileSystemEventHandler
):
def
__init__
(
self
,
paths
,
on_change
):
self
.
dirs
=
defaultdict
(
list
)
self
.
on_change
=
on_change
self
.
observer
=
Observer
()
for
path
in
paths
:
self
.
add_module
(
path
)
self
.
observer
.
start
()
def
add_module
(
self
,
path
):
"""Add a python module to track changes to"""
path
=
os
.
path
.
abspath
(
path
)
for
suff
in
importcompletion
.
SUFFIXES
:
if
path
.
endswith
(
suff
):
path
=
path
[:
-
len
(
suff
)]
break
dirname
=
os
.
path
.
dirname
(
path
)
if
dirname
not
in
self
.
dirs
:
self
.
observer
.
schedule
(
self
,
dirname
,
recursive
=
False
)
self
.
dirs
[
os
.
path
.
dirname
(
path
)].
append
(
path
)
def
on_any_event
(
self
,
event
):
dirpath
=
os
.
path
.
dirname
(
event
.
src_path
)
paths
=
[
path
+
suffix
for
suffix
in
importcompletion
.
SUFFIXES
for
path
in
self
.
dirs
[
dirpath
]]
if
event
.
src_path
in
paths
:
pass
#self.on_change()
self
.
on_change
()
if
__name__
==
'__main__'
:
m
=
ModuleChangedEventHandler
([])
m
.
add_module
(
'./wdtest.py'
)
try
:
while
True
:
time
.
sleep
(
1
)
except
KeyboardInterrupt
:
m
.
observer
.
stop
()
m
.
observer
.
join
()
Back
|
FazBrowse Home
|
New Git URL