[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819
Sebastian Krzyszkowiak
seba.dos1 at gmail.com
Sat Aug 6 08:17:39 UTC 2011
The following commit has been merged in the debian branch:
commit 1099a55dc5b9e23304e903d1429b8537df68e0af
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date: Sat Aug 1 20:40:25 2009 +0200
opimd: fix imports and move QueryMatcher class into query_manager.py
diff --git a/framework/subsystems/opimd/backend_manager.py b/framework/subsystems/opimd/backend_manager.py
index cd6df84..20f3263 100644
--- a/framework/subsystems/opimd/backend_manager.py
+++ b/framework/subsystems/opimd/backend_manager.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
"""
Open PIM Daemon
@@ -11,9 +12,12 @@ GPLv2 or later
Backend plugin manager
"""
+DBUS_BUS_NAME_FSO = "org.freesmartphone.opimd"
+DBUS_PATH_BASE_FSO = "/org/freesmartphone/PIM"
+DIN_BASE_FSO = "org.freesmartphone.PIM"
+
from domain_manager import DomainManager
from helpers import *
-from opimd import *
import framework.patterns.tasklet as tasklet
from framework.config import config, busmap
diff --git a/framework/subsystems/opimd/domain_manager.py b/framework/subsystems/opimd/domain_manager.py
index 224c069..2c6a8f5 100644
--- a/framework/subsystems/opimd/domain_manager.py
+++ b/framework/subsystems/opimd/domain_manager.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
#
# Openmoko PIM Daemon
# Domain Plugin Manager
@@ -24,12 +25,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-"""pypimd Domain Plugin Manager"""
+"""opimd Domain Plugin Manager"""
MODULE_NAME = "opimd"
from dbus.service import FallbackObject as DBusFBObject
-from opimd import *
import logging
logger = logging.getLogger( MODULE_NAME )
diff --git a/framework/subsystems/opimd/opimd.py b/framework/subsystems/opimd/opimd.py
index 44275ac..e6baca4 100644
--- a/framework/subsystems/opimd/opimd.py
+++ b/framework/subsystems/opimd/opimd.py
@@ -36,8 +36,6 @@ DIN_BASE = None
MODULE_NAME = "opimd"
-from opimd import *
-
# We import the domain modules, so that there classes get registered
import pimd_contacts
import pimd_messages
diff --git a/framework/subsystems/opimd/pimd_generic.py b/framework/subsystems/opimd/pimd_generic.py
index c61e297..8cc3f58 100644
--- a/framework/subsystems/opimd/pimd_generic.py
+++ b/framework/subsystems/opimd/pimd_generic.py
@@ -23,6 +23,8 @@ import re
import logging
logger = logging.getLogger('opimd')
+from query_manager import QueryMatcher
+
from backend_manager import BackendManager
from backend_manager import PIMB_CAN_ADD_ENTRY, PIMB_CAN_DEL_ENTRY, PIMB_CAN_UPD_ENTRY, PIMB_CAN_UPD_ENTRY_WITH_NEW_FIELD, PIMB_NEEDS_SYNC
@@ -45,61 +47,6 @@ _DIN_ENTRIES = _DIN_DOMAIN_BASE + '.' + 'Entries'
_DIN_ENTRY = _DIN_DOMAIN_BASE + '.' + 'Entry'
_DIN_QUERY = _DIN_DOMAIN_BASE + '.' + 'EntryQuery'
-#----------------------------------------------------------------------------#
-class QueryMatcher(object):
-#----------------------------------------------------------------------------#
- query_obj = None
-
- def __init__(self, query):
- """Evaluates a query
-
- @param query Query to evaluate, must be a dict"""
-
- self.query_obj = query
-
- def single_entry_matches(self, entry):
- assert(self.query_obj, "Query object is empty, cannot match!")
-
- if entry:
- return entry.match_query(self.query_obj)
- else:
- return False
-
- def match(self, entries):
- """Tries to match a given set of entries to the current query
-
- @param entries List of Entry objects
- @return List of entry IDs that match"""
-
- assert(self.query_obj, "Query object is empty, cannot match!")
-
- matches = []
- results = []
-
- # Match all entires
- for (entry_id, entry) in enumerate(entries):
- match = self.single_call_matches(entry)
- if match:
- matches.append((match, entry_id))
-
- result_count = len(matches)
- # Sort matches by relevance and return the best hits
- if result_count > 0:
- matches.sort(reverse = True)
-
- limit = result_count
- if self.query_obj.has_key("_limit"):
- limit = self.query_obj["_limit"]
- if limit > result_count:
- limit = result_count
-
- # Append the entry IDs to the result list in the order of the sorted list
- for i in range(limit):
- results.append(matches[i][1])
-
- return results
-
-
#----------------------------------------------------------------------------#
class Entry():
diff --git a/framework/subsystems/opimd/query_manager.py b/framework/subsystems/opimd/query_manager.py
new file mode 100644
index 0000000..8fd9184
--- /dev/null
+++ b/framework/subsystems/opimd/query_manager.py
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+#
+# Open PIM Daemon
+# Query Plugin Manager
+#
+# http://freesmartphone.org/
+#
+# Copyright (C) 2008 by Soeren Apel (abraxa at dar-clan.de)
+# Copyright (C) 2008-2009 by Openmoko, Inc.
+# Copyright (C) 2009 Michael 'Mickey' Lauer <mlauer at vanille-media.de>
+# Copyright (C) 2009 Sebastian dos Krzyszkowiak <seba.dos1 at gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+"""opimd Query Plugin Manager"""
+
+MODULE_NAME = "opimd"
+
+from dbus.service import FallbackObject as DBusFBObject
+from opimd import *
+
+import logging
+logger = logging.getLogger( MODULE_NAME )
+
+#----------------------------------------------------------------------------#
+class QueryMatcher(object):
+#----------------------------------------------------------------------------#
+ query_obj = None
+
+ def __init__(self, query):
+ """Evaluates a query
+
+ @param query Query to evaluate, must be a dict"""
+
+ self.query_obj = query
+
+ def single_entry_matches(self, entry):
+ assert(self.query_obj, "Query object is empty, cannot match!")
+
+ if entry:
+ return entry.match_query(self.query_obj)
+ else:
+ return False
+
+ def match(self, entries):
+ """Tries to match a given set of entries to the current query
+
+ @param entries List of Entry objects
+ @return List of entry IDs that match"""
+
+ assert(self.query_obj, "Query object is empty, cannot match!")
+
+ matches = []
+ results = []
+
+ # Match all entires
+ for (entry_id, entry) in enumerate(entries):
+ match = self.single_call_matches(entry)
+ if match:
+ matches.append((match, entry_id))
+
+ result_count = len(matches)
+ # Sort matches by relevance and return the best hits
+ if result_count > 0:
+ matches.sort(reverse = True)
+
+ limit = result_count
+ if self.query_obj.has_key("_limit"):
+ limit = self.query_obj["_limit"]
+ if limit > result_count:
+ limit = result_count
+
+ # Append the entry IDs to the result list in the order of the sorted list
+ for i in range(limit):
+ results.append(matches[i][1])
+
+ return results
+
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list