Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes to chown. closes #34

  • Loading branch information...
commit e38fa31f36901f309769403a759979b853983d77 1 parent cb7bd87
Tomer Filiba authored October 06, 2012
2  .gitattributes
... ...
@@ -0,0 +1,2 @@
  1
+*.py text eol=lf
  2
+*.rst text eol=lf
20  plumbum/cmd.py
... ...
@@ -1,20 +0,0 @@
1  
-"""
2  
-Module hack: ``from plumbum.cmd import ls``
3  
-"""
4  
-import sys
5  
-from types import ModuleType
6  
-from plumbum.local_machine import local
7  
-
8  
-__all__ = []
9  
-
10  
-class LocalModule(ModuleType):
11  
-    """The module-hack that allows us to use ``from plumbum.cmd import some_program``"""
12  
-    def __init__(self, name):
13  
-        ModuleType.__init__(self, name, __doc__)
14  
-        self.__file__ = None
15  
-        self.__package__ = ".".join(name.split(".")[:-1])
16  
-    def __getattr__(self, name):
17  
-        return local[name]
18  
-
19  
-LocalModule = LocalModule("plumbum.cmd")
20  
-sys.modules[LocalModule.__name__] = LocalModule
17  plumbum/local_machine.py
@@ -7,16 +7,17 @@
7 7
 import logging
8 8
 import stat
9 9
 import time
  10
+import platform
10 11
 from tempfile import mkdtemp
11 12
 from subprocess import Popen, PIPE
12 13
 from contextlib import contextmanager
  14
+from types import ModuleType
13 15
 
14 16
 from plumbum.path import Path, FSUser
15 17
 from plumbum.remote_path import RemotePath
16 18
 from plumbum.commands import CommandNotFound, ConcreteCommand
17 19
 from plumbum.session import ShellSession
18 20
 from plumbum.lib import _setdoc
19  
-import platform
20 21
 
21 22
 try:
22 23
     from pwd import getpwuid, getpwnam
@@ -580,3 +581,17 @@ def tempdir(self):
580 581
 * ``encoding`` - the local machine's default encoding (``sys.getfilesystemencoding()``)
581 582
 """
582 583
 
  584
+#===================================================================================================
  585
+# Module hack: ``from plumbum.cmd import ls``
  586
+#===================================================================================================
  587
+class LocalModule(ModuleType):
  588
+    """The module-hack that allows us to use ``from plumbum.cmd import some_program``"""
  589
+    def __init__(self, name):
  590
+        ModuleType.__init__(self, name, __doc__)
  591
+        self.__file__ = None
  592
+        self.__package__ = ".".join(name.split(".")[:-1])
  593
+    def __getattr__(self, name):
  594
+        return local[name]
  595
+
  596
+LocalModule = LocalModule("plumbum.cmd")
  597
+sys.modules[LocalModule.__name__] = LocalModule
3  tests/test_local.py
@@ -15,9 +15,8 @@ def test_basename(self):
15 15
     def test_dirname(self):
16 16
         name = LocalPath("/some/long/path/to/file.txt").dirname
17 17
         self.assertTrue(isinstance(name, LocalPath))
18  
-        self.assertEqual("/some/long/path/to", str(name))
  18
+        self.assertEqual("/some/long/path/to", str(name).replace("\\", "/"))
19 19
 
20  
-    # requires being run as root
21 20
     def _test_chown(self):
22 21
         path = LocalPath("/tmp/delme.txt")
23 22
         path.delete()

0 notes on commit e38fa31

Please sign in to comment.
Something went wrong with that request. Please try again.