<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12129] twext/trunk/twext/who/opendirectory</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12129">12129</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-12-18 11:29:44 -0800 (Wed, 18 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>cleanup</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#twexttrunktwextwhoopendirectory__init__py">twext/trunk/twext/who/opendirectory/__init__.py</a></li>
<li><a href="#twexttrunktwextwhoopendirectoryodframeworkpy">twext/trunk/twext/who/opendirectory/odframework.py</a></li>
<li><a href="#twexttrunktwextwhoopendirectoryservicepy">twext/trunk/twext/who/opendirectory/service.py</a></li>
<li><a href="#twexttrunktwextwhoopendirectorytesttest_servicepy">twext/trunk/twext/who/opendirectory/test/test_service.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="twexttrunktwextwhoopendirectory__init__py"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/__init__.py (12128 => 12129)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/__init__.py        2013-12-18 19:02:46 UTC (rev 12128)
+++ twext/trunk/twext/who/opendirectory/__init__.py        2013-12-18 19:29:44 UTC (rev 12129)
</span><span class="lines">@@ -14,10 +14,19 @@
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot;
+OpenDirectory directory service.
+&quot;&quot;&quot;
+
</ins><span class="cx"> __all__ = [
</span><ins>+    &quot;OpenDirectoryError&quot;,
+    &quot;OpenDirectoryConnectionError&quot;,
+    &quot;OpenDirectoryQueryError&quot;,
</ins><span class="cx">     &quot;DirectoryService&quot;,
</span><span class="cx">     &quot;DirectoryRecord&quot;,
</span><span class="cx"> ]
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+from .service import OpenDirectoryError
+from .service import OpenDirectoryConnectionError, OpenDirectoryQueryError
</ins><span class="cx"> from .service import DirectoryService, DirectoryRecord
</span></span></pre></div>
<a id="twexttrunktwextwhoopendirectoryodframeworkpy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/odframework.py (12128 => 12129)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/odframework.py        2013-12-18 19:02:46 UTC (rev 12128)
+++ twext/trunk/twext/who/opendirectory/odframework.py        2013-12-18 19:29:44 UTC (rev 12129)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+##
+# Copyright (c) 2013 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+&quot;&quot;&quot;
+OpenDirectory.framework
+&quot;&quot;&quot;
+
</ins><span class="cx"> import objc as _objc
</span><span class="cx"> 
</span><span class="cx"> __bundle__ = _objc.initFrameworkWrapper(
</span></span></pre></div>
<a id="twexttrunktwextwhoopendirectoryservicepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/service.py (12128 => 12129)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/service.py        2013-12-18 19:02:46 UTC (rev 12128)
+++ twext/trunk/twext/who/opendirectory/service.py        2013-12-18 19:29:44 UTC (rev 12129)
</span><span class="lines">@@ -21,12 +21,6 @@
</span><span class="cx"> OpenDirectory directory service implementation.
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-__all__ = [
-    &quot;OpenDirectoryError&quot;,
-    &quot;DirectoryService&quot;,
-    &quot;DirectoryRecord&quot;,
-]
-
</del><span class="cx"> from itertools import chain
</span><span class="cx"> 
</span><span class="cx"> from odframework import ODSession, ODNode, ODQuery
</span><span class="lines">@@ -350,13 +344,16 @@
</span><span class="cx">                 )
</span><span class="cx">             odAttr = ODAttribute.fromFieldName(expression.fieldName).value
</span><span class="cx">             queryString = {
</span><del>-                ODMatchType.equals.value      : u&quot;(%s=%s)&quot;,
-                ODMatchType.startsWith.value  : u&quot;(%s=%s*)&quot;,
-                ODMatchType.endsWith.value    : u&quot;(%s=*%s)&quot;,
-                ODMatchType.contains.value    : u&quot;(%s=*%s*)&quot;,
-                ODMatchType.lessThan.value    : u&quot;(%s&lt;%s)&quot;,
-                ODMatchType.greaterThan.value : u&quot;(%s&gt;%s)&quot;,
-            }.get(matchType.value, u&quot;(%s=*%s*)&quot;) % (odAttr, expression.fieldValue,)
</del><ins>+                ODMatchType.equals.value: u&quot;({attr}={value})&quot;,
+                ODMatchType.startsWith.value: u&quot;({attr}={value}*)&quot;,
+                ODMatchType.endsWith.value: u&quot;({attr}=*{value})&quot;,
+                ODMatchType.contains.value: u&quot;({attr}=*{value}*)&quot;,
+                ODMatchType.lessThan.value: u&quot;({attr}&lt;{value})&quot;,
+                ODMatchType.greaterThan.value: u&quot;({attr}&gt;{value})&quot;,
+            }.get(matchType.value, u&quot;({attr}=*{value}*)&quot;).format(
+                attr=odAttr,
+                value=expression.fieldValue
+            )
</ins><span class="cx"> 
</span><span class="cx">         elif isinstance(expression, CompoundExpression):
</span><span class="cx">             queryString = u&quot;&quot;
</span><span class="lines">@@ -615,22 +612,25 @@
</span><span class="cx">         # &quot;Local node = {service.localNode}\n&quot;
</span><span class="cx">         .format(service=service)
</span><span class="cx">     )
</span><ins>+    print(&quot;-&quot; * 80)
</ins><span class="cx"> 
</span><del>-    for shortName in sys.argv:
-        print(&quot;=&quot; * 80)
</del><ins>+    for shortName in sys.argv[1:]:
+        print(&quot;Looking up short name: {0}&quot;.format(shortName))
+
</ins><span class="cx">         matchExpression = MatchExpression(
</span><span class="cx">             service.fieldName.shortNames, shortName,
</span><span class="cx">             matchType=MatchType.equals,
</span><span class="cx">         )
</span><span class="cx">         queryString = service._queryStringFromExpression(matchExpression)
</span><del>-        print(&quot;{name} via MatchExpression using query {query}&quot;.format(
-            name=shortName, query=queryString))
</del><ins>+        print(
+            &quot;\n...via MatchExpression, query={query!r}&quot;
+            .format(query=queryString)
+        )
+        print()
+
</ins><span class="cx">         for record in service.recordsFromExpression(matchExpression):
</span><del>-            print(&quot;*&quot; * 80)
</del><span class="cx">             print(record.description())
</span><span class="cx"> 
</span><del>-        print(&quot;=&quot; * 80)
-
</del><span class="cx">         compoundExpression = CompoundExpression(
</span><span class="cx">             [
</span><span class="cx">                 MatchExpression(
</span><span class="lines">@@ -643,10 +643,14 @@
</span><span class="cx">                 ),
</span><span class="cx">             ],
</span><span class="cx">             Operand.OR
</span><del>-        ) 
</del><ins>+        )
</ins><span class="cx">         queryString = service._queryStringFromExpression(compoundExpression)
</span><del>-        print(&quot;{name} via CompoundExpression using query {query}&quot;.format(
-            name=shortName, query=queryString))
</del><ins>+        print(
+            &quot;\n...via CompoundExpression, query={query!r}&quot;
+            .format(query=queryString)
+        )
+        print()
+
</ins><span class="cx">         for record in service.recordsFromExpression(compoundExpression):
</span><del>-            print(&quot;*&quot; * 80)
</del><span class="cx">             print(record.description())
</span><ins>+            print()
</ins></span></pre></div>
<a id="twexttrunktwextwhoopendirectorytesttest_servicepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/opendirectory/test/test_service.py (12128 => 12129)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/opendirectory/test/test_service.py        2013-12-18 19:02:46 UTC (rev 12128)
+++ twext/trunk/twext/who/opendirectory/test/test_service.py        2013-12-18 19:29:44 UTC (rev 12129)
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-
-
</del><span class="cx"> class OpenDirectoryServiceTestCase(unittest.TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Tests for L{DirectoryService}.
</span><span class="lines">@@ -49,8 +47,10 @@
</span><span class="cx">                 matchType=matchType
</span><span class="cx">             )
</span><span class="cx">             queryString = service._queryStringFromExpression(expression)
</span><del>-            self.assertEquals(queryString,
-                u&quot;(dsAttrTypeStandard:RecordName{exp})&quot;.format(exp=expected))
</del><ins>+            self.assertEquals(
+                queryString,
+                u&quot;(dsAttrTypeStandard:RecordName{exp})&quot;.format(exp=expected)
+            )
</ins><span class="cx"> 
</span><span class="cx">         # CompoundExpressions
</span><span class="cx"> 
</span><span class="lines">@@ -78,14 +78,17 @@
</span><span class="cx">                 ),
</span><span class="cx">             ],
</span><span class="cx">             Operand.AND
</span><del>-        ) 
</del><ins>+        )
</ins><span class="cx">         queryString = service._queryStringFromExpression(expression)
</span><del>-        self.assertEquals(queryString,
-            u&quot;(&amp;(dsAttrTypeStandard:GeneratedUID=*a*)&quot;
-             &quot;(dsAttrTypeStandard:GeneratedUID=*b*)&quot;
-             &quot;(dsAttrTypeStandard:RecordName=*c*)&quot;
-             &quot;(dsAttrTypeStandard:EMailAddress=d*)&quot;
-             &quot;(dsAttrTypeStandard:RealName=e))&quot;
</del><ins>+        self.assertEquals(
+            queryString,
+            (
+                u&quot;(&amp;(dsAttrTypeStandard:GeneratedUID=*a*)&quot;
+                u&quot;(dsAttrTypeStandard:GeneratedUID=*b*)&quot;
+                u&quot;(dsAttrTypeStandard:RecordName=*c*)&quot;
+                u&quot;(dsAttrTypeStandard:EMailAddress=d*)&quot;
+                u&quot;(dsAttrTypeStandard:RealName=e))&quot;
+            )
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         expression = CompoundExpression(
</span><span class="lines">@@ -104,10 +107,13 @@
</span><span class="cx">                 ),
</span><span class="cx">             ],
</span><span class="cx">             Operand.OR
</span><del>-        ) 
</del><ins>+        )
</ins><span class="cx">         queryString = service._queryStringFromExpression(expression)
</span><del>-        self.assertEquals(queryString,
-            u&quot;(|(dsAttrTypeStandard:RecordName=*a*)&quot;
-             &quot;(dsAttrTypeStandard:EMailAddress=b*)&quot;
-             &quot;(dsAttrTypeStandard:RealName=c))&quot;
</del><ins>+        self.assertEquals(
+            queryString,
+            (
+                u&quot;(|(dsAttrTypeStandard:RecordName=*a*)&quot;
+                u&quot;(dsAttrTypeStandard:EMailAddress=b*)&quot;
+                u&quot;(dsAttrTypeStandard:RealName=c))&quot;
+            )
</ins><span class="cx">         )
</span></span></pre>
</div>
</div>

</body>
</html>