Commits

Ali Gholami Rudi  committed 83e2bee

Changing star imports from package
Raising exceptions when moving a module to a nonexistent package

  • Participants
  • Parent commits 7472f78

Comments (0)

Files changed (9)

File docs/dev/issues.txt

 information and testing.
 
 
+Using A Database
+----------------
+
+The shelve module fails mysteriously sometimes.  For this reason I
+think using a database for saving our object information would
+help us get rid of some of the problems.  After a few inspections
+and testing options I decided to do one of the followings:
+
+Using SQLAlchemy
+----------------
+
+SQLAlchemy is a nice tool.  But there are problems:
+
+* Requiring a third party library
+* I could not find a good way to create tables using classes and not
+  using `sqlalchemy.Table` function.
+
+
+Using Sqlite3 directly
+----------------------
+
+The good thing about using sqlite3 is that it is always available in
+Python 2.5.  The problem is that it requires using SQL inside python
+source code.  It makes changing the DB a really hard task.  And
+refactorings cannot be used to add columns or rename them.
+
+The queries and commands that we need:
+
+* ``select * from per_name where scope_id=? and name=?``
+* ``insert into per_name (name, value) values (?, ?)``
+* ``update per_name set value=? where scope_id=? and name=?``
+* ``delete from users where scope_id=?``
+
+* ``select * from call_info where scope_id=?``
+* ``select * from call_info where scope_id=? and args=?``
+* ``insert into call_info (args, returned) values (?, ?)``
+* ``update call_info set returned=? where scope_id=? and name=?``
+* ``delete from call_info where scope_id=?``
+
+* ``select * from scopes``
+* ``insert into scopes (path, key) values (?, ?)``
+* ``select scope_id from scopes where path=? key=?``
+* ``delete from scopes where file=? key=?``
+
+
+Maybe we can make it a bit easier by using a helper class::
+
+  class Table(object):
+
+      def __init__(self):
+          pass
+
+      def select(self, **kwds):
+          pass
+
+      def insert(self, **kwds):
+          pass
+
+      def delete(self, **kwds):
+          pass
+
+      def update(self, command, **kwds):
+          pass
+
+
+  def create_table(name, **fields):
+      pass
+
+  scopes = create_table('scopes', scope_id='INTEGER',
+                        file='CHAR(255)', key='CHAR(255)')
+
+  scopes.insert(file='myfile', key='mykey')
+
+
+Implementing A Simple ORM
+-------------------------
+
+I don't want to put much time on it.  My needs are simple.  Lets
+estimate the amount of work needed for it.
+
+* Integer, CHAR, ForeignKey
+* Only one to many relations
+* SELECT *
+* SELECT * where attr=x
+* INSERT
+* UPDATE
+* DELETE
+* ...
+
+This means lots of work and I will give up!
+
+
 Better Concluded Data
 =====================
 

File docs/dev/workingon.txt

 Small Stories
 =============
 
-* Using _MoveTools in MoveMethod
+- Changing star import from packages to include everything; even
+  all its sum-modules
+- Raising exceptions when moving a module to a nonexistent package
 
+Possible plans for the next release:
+
+* Better concluded data
+* Using DBs in ObjectInfoManager
+* Adding call for UI contributions section and interesting tasks
+* Document features and organize them
 * Annotation and tags in source code; not changing the source?
 
 

File rope/base/pynames.py

 
     def get_names(self):
         if self.names.get() is None:
-            if isinstance(self.imported_module.get_object(),
-                          rope.base.pyobjects.PyPackage):
-                return {}
+            # NOTE: importing everything from packages; all submodules!
+            #if isinstance(self.imported_module.get_object(),
+            #              rope.base.pyobjects.PyPackage):
+            #    return {}
             result = {}
             imported = self.imported_module.get_object()
             for name, pyname in imported.get_attributes().iteritems():

File rope/refactor/move.py

 
     def get_changes(self, dest, task_handle=taskhandle.NullTaskHandle()):
         moving_pyobject = self.old_pyname.get_object()
-        if not dest.is_folder():
+        if dest is None or not dest.is_folder():
             raise exceptions.RefactoringError(
                 'Move destination for modules should be packages.')
         changes = ChangeSet('Moving module <%s>' % self.old_name)
 
     def rename_in_module(self, new_name, pymodule=None,
                           imports=False, resource=None):
-        # IDEA: Maybe we can cache occurrence finders
         occurrence_finder = occurrences.FilteredFinder(
             self.pycore, self.old_name, [self.old_pyname], imports=imports)
         source = rename.rename_in_module(

File rope/ui/fill.py

         first_indents, indents = self._find_indents(lines)
         is_list = self._is_list(text)
         break_first = first_indents != indents
-        if is_list and indents is None:
+        if is_list:
             indents = first_indents + 2
             break_first = False
 

File ropetest/ide/codeassisttest.py

         result = self.assist.assist(code, len(code))
         self.assert_completion_in_result('nestedmod', 'global', result)
 
-    def test_from_package_import_star(self):
-        code = 'from package import *\nnest'
-        result = self.assist.assist(code, len(code))
-        self.assert_completion_not_in_result('nestedmod', 'global', result)
-
     def test_completing_after_dot(self):
         code = 'class SampleClass(object):\n    def sample_method(self):\n        pass\nSampleClass.sam'
         result = self.assist.assist(code, len(code))

File ropetest/pycoretest.py

         self.assertEquals(get_base_type('Module'),
                           mod.get_attribute('nestedmod').get_object().get_type())
 
-    def test_from_package_import_star(self):
-        mod = self.pycore.get_string_module('from package import *\nnest')
+    # XXX: Deciding to import everything on import start from packages
+    def xxx_test_from_package_import_star(self):
+        mod = self.pycore.get_string_module('from package import *\n')
         self.assertTrue('nestedmod' not in mod.get_attributes())
 
     def test_unknown_when_module_cannot_be_found(self):

File ropetest/refactor/movetest.py

         self.assertEquals('import os\nimport mod4\n\n\n'
                           'print mod4.a_var\n', self.mod2.read())
 
+    @testutils.assert_raises(exceptions.RefactoringError)
+    def test_moving_module_refactoring_and_nonexistent_destinations(self):
+        self.mod4.write('a_var = 1')
+        self.mod2.write('from pkg import mod4\n'
+                        'import os\n\n\nprint mod4.a_var\n')
+        mover = move.create_move(self.project, self.mod4)
+        mover.get_changes(None).do()
+
     def test_moving_methods_choosing_the_correct_class(self):
         code = 'class A(object):\n    def a_method(self):\n        pass\n'
         self.mod1.write(code)

File ropetest/ui/filltest.py

         self.assertEquals('name\n  value',
                           self.fill.fill('name\n  value'))
 
+    def test_handling_simple_unordered_lists(self):
+        self.assertEquals('* simple\n  word in\n  list',
+                          self.fill.fill('* simple word\n  in list'))
+
 
 if __name__ == '__main__':
     unittest.main()