summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/helper.py5
-rw-r--r--ranger/core/main.py28
2 files changed, 32 insertions, 1 deletions
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index 88072e13..446d9328 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -68,6 +68,11 @@ def parse_arguments():
 			help="List common keys which are not bound to any action.")
 	parser.add_option('--selectfile', type='string', metavar='filepath',
 			help="Open ranger with supplied file selected.")
+	parser.add_option('--list-tagged-files', type='string', default=None,
+			metavar='tag',
+			help="List all files which are tagged with the given tag, default: *")
+	parser.add_option('--profile', action='store_true',
+			help="Print statistics of CPU usage on exit.")
 
 	options, positional = parser.parse_args()
 	arg = OpenStruct(options.__dict__, targets=positional)
diff --git a/ranger/core/main.py b/ranger/core/main.py
index b69e3c6d..1c2686bb 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -46,6 +46,20 @@ def main():
 		fm = FM()
 		fm.copy_config_files(arg.copy_config)
 		return 1 if arg.fail_unless_cd else 0
+	if arg.list_tagged_files:
+		fm = FM()
+		try:
+			f = open(fm.confpath('tagged'), 'r')
+		except:
+			pass
+		else:
+			for line in f.readlines():
+				if len(line) > 2 and line[1] == ':':
+					if line[0] in arg.list_tagged_files:
+						sys.stdout.write(line[2:])
+				elif len(line) > 0 and '*' in arg.list_tagged_files:
+					sys.stdout.write(line)
+		return 1 if arg.fail_unless_cd else 0
 
 	SettingsAware._setup(clean=arg.clean)
 
@@ -107,7 +121,15 @@ def main():
 		# Run the file manager
 		fm.initialize()
 		fm.ui.initialize()
-		fm.loop()
+		if ranger.arg.profile:
+			import cProfile
+			import pstats
+			profile = None
+			ranger.__fm = fm
+			cProfile.run('ranger.__fm.loop()', '/tmp/ranger_profile')
+			profile = pstats.Stats('/tmp/ranger_profile')
+		else:
+			fm.loop()
 	except Exception:
 		import traceback
 		crash_traceback = traceback.format_exc()
@@ -123,6 +145,10 @@ def main():
 			fm.ui.destroy()
 		except (AttributeError, NameError):
 			pass
+		if ranger.arg.profile and profile:
+			stdout, sys.stdout = sys.stdout, sys.stderr
+			profile.strip_dirs().sort_stats('cumulative').print_callees(100)
+			sys.stdout = stdout
 		if crash_traceback:
 			print("ranger version: %s, executed with python %s" %
 					(ranger.__version__, sys.version.split()[0]))
href='/akkartik/mu/commit/examples/ex9.subx?h=main&id=7a5832204a80ff43d23c3a384c26e2217ef5908b'>7a583220 ^
33352536 ^
9d27e966 ^

33352536 ^
9d27e966 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
ecfbbfb5 ^
33352536 ^
ecfbbfb5 ^
d9818a53 ^
71eb22a5 ^
33352536 ^
98d45d34 ^
33352536 ^

98d45d34 ^
33352536 ^
6030d7e2 ^
33352536 ^
6030d7e2 ^
ed0e64a9 ^
ee9a9237 ^
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
49
50
51
52