summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-11-24 02:02:04 +0100
committerhut <hut@lavabit.com>2009-11-24 02:02:04 +0100
commit798d06a2317a5bb4ee38cec4d1d4f5d428d75593 (patch)
tree335fa4def2632c91acd11e4cee9aac32f9ddd15b
parent556d84cd0fa94372c3fc2eb722f6925e61c42778 (diff)
downloadranger-798d06a2317a5bb4ee38cec4d1d4f5d428d75593.tar.gz
stuff
-rw-r--r--code/directory.py15
-rw-r--r--code/fm.py4
-rw-r--r--code/fsobject.py9
-rw-r--r--code/ui.py6
-rw-r--r--ranger2
-rw-r--r--test/tc_directory.py3
6 files changed, 30 insertions, 9 deletions
diff --git a/code/directory.py b/code/directory.py
index ef68d35f..da7c0948 100644
--- a/code/directory.py
+++ b/code/directory.py
@@ -1,5 +1,5 @@
 import fsobject
-import file
+import file, debug
 
 class Directory(fsobject.FSObject):
 	def __init__(self, path):
@@ -19,10 +19,17 @@ class Directory(fsobject.FSObject):
 		self.content_loaded = True
 		import os
 		if self.exists:
-			self.filenames = os.listdir(self.path)
+			basenames = os.listdir(self.path)
+			mapped = map(lambda name: os.path.join(self.path, name), basenames)
+			self.filenames = list(mapped)
+			self.infostring = ' %d' % len(self.filenames)
+			debug.log('infostring set!')
 			self.files = []
 			for name in self.filenames:
-				f = file.File(name)
+				if os.path.isdir(name):
+					f = Directory(name)
+				else:
+					f = file.File(name)
 				f.load()
 				self.files.append(f)
 	
@@ -36,7 +43,7 @@ class Directory(fsobject.FSObject):
 	
 	def __getitem__(self, key):
 		if not self.accessible: raise fsobject.NotLoadedYet()
-		return self.filenames[key]
+		return self.files[key]
 
 if __name__ == '__main__':
 	d = Directory('.')
diff --git a/code/fm.py b/code/fm.py
index c2fe30a4..6631aee4 100644
--- a/code/fm.py
+++ b/code/fm.py
@@ -1,5 +1,5 @@
 import sys
-import ui, debug, directory
+import ui, debug, directory, fstype
 
 class FM():
 	def __init__(self, options, environment):
@@ -25,6 +25,8 @@ class FM():
 		try:
 			while 1:
 				try:
+#					if type(self.env.cf) is directory.Directory:
+#						self.env.cf.load_content_once()
 					self.ui.feed(self.env.directories, self.env.pwd, self.env.cf, self.env.termsize)
 					self.ui.draw()
 				except KeyboardInterrupt:
diff --git a/code/fsobject.py b/code/fsobject.py
index 1e194ac9..148976d2 100644
--- a/code/fsobject.py
+++ b/code/fsobject.py
@@ -17,6 +17,8 @@ class FSObject(object):
 		self.islink = False
 		self.brokenlink = False
 		self.stat = None
+		self.infostring = None
+		self.permissions = None
 		self.type = fstype.Unknown
 
 	# load() reads useful information about the file from the file system
@@ -34,10 +36,17 @@ class FSObject(object):
 
 			if os.path.isdir(self.path):
 				self.type = fstype.Directory
+				self.infostring = '--'
 			elif os.path.isfile(self.path):
 				self.type = fstype.File
+				self.infostring = ' %d' % self.stat.st_size
+			else:
+				self.type = fstype.Unknown
+				self.infostring = None
+
 		except OSError:
 			self.islink = False
+			self.infostring = None
 			self.type = fstype.Nonexistent
 			self.exists = False
 			self.accessible = False
diff --git a/code/ui.py b/code/ui.py
index 7d8fd828..3994d7ce 100644
--- a/code/ui.py
+++ b/code/ui.py
@@ -1,4 +1,4 @@
-import curses
+import curses, debug
 class UI():
 	def __init__(self, options):
 		self.scr = curses.initscr()
@@ -31,7 +31,9 @@ class UI():
 		import time
 		self.scr.erase()
 		for i in range(1, len(self.pwd)):
-			self.scr.addstr(i, 0, self.pwd[i])
+			f = self.pwd.files[i]
+			self.scr.addstr(i, 0, f.path)
+			if f.infostring: self.scr.addstr(i, 50, f.infostring)
 		self.scr.refresh()
 
 	def get_next_key(self):
diff --git a/ranger b/ranger
index 8e63ec86..4973e42f 100644
--- a/ranger
+++ b/ranger
@@ -15,7 +15,7 @@ def main():
 	import locale
 	locale.setlocale(locale.LC_ALL, 'en_US.utf8')
 
-	path = '.'
+	path = '..'
 	opt = options.get()
 	env = environment.Environment()
 
diff --git a/test/tc_directory.py b/test/tc_directory.py
index 69717ba2..f97f9913 100644
--- a/test/tc_directory.py
+++ b/test/tc_directory.py
@@ -1,7 +1,7 @@
 import unittest
 import sys, os
 sys.path.append('../code')
-import directory, fsobject, file
+import directory, fsobject, file, debug
 
 TESTDIR = os.path.realpath(os.path.join(os.path.dirname(sys.argv[0]), 'testdir'))
 TESTFILE = os.path.join(TESTDIR, 'testfile5234148')
@@ -30,6 +30,7 @@ class Test1(unittest.TestCase):
 		# Get the filenames you expect it to have and sort both before
 		# comparing. I don't expect any order after only loading the filenames.
 		assumed_filenames = os.listdir(TESTDIR)
+		assumed_filenames = list(map(lambda str: os.path.join(TESTDIR, str), assumed_filenames))
 		assumed_filenames.sort()
 		dir.filenames.sort()
 
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854