From 5902a5e52119a297ee842e8ccb9140e3f11d2ec1 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 4 Oct 2013 13:00:55 -0700 Subject: [PATCH] frozendict now as submodule in third_party --- .gitmodules | 3 ++ python/ycm/frozendict.py | 54 -------------------------------- python/ycm/user_options_store.py | 2 +- third_party/frozendict | 1 + 4 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 python/ycm/frozendict.py create mode 160000 third_party/frozendict diff --git a/.gitmodules b/.gitmodules index f94366c0..a0e24625 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "third_party/bottle"] path = third_party/bottle url = https://github.com/defnull/bottle +[submodule "third_party/frozendict"] + path = third_party/frozendict + url = https://github.com/slezica/python-frozendict diff --git a/python/ycm/frozendict.py b/python/ycm/frozendict.py deleted file mode 100644 index ec0aa5ad..00000000 --- a/python/ycm/frozendict.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Source: https://github.com/slezica/python-frozendict -# -# Copyright (c) 2012 Santiago Lezica -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -import collections, operator - -class frozendict(collections.Mapping): - - def __init__(self, *args, **kwargs): - self.__dict = dict(*args, **kwargs) - self.__hash = None - - def __getitem__(self, key): - return self.__dict[key] - - def copy(self, **add_or_replace): - new = frozendict(self) - new.__dict.update(add_or_replace) # Feels like cheating - return new - - def __iter__(self): - return iter(self.__dict) - - def __len__(self): - return len(self.__dict) - - def __repr__(self): - return '' % repr(self.__dict) - - def __hash__(self): - if self.__hash is None: - self.__hash = reduce(operator.xor, map(hash, self.iteritems()), 0) - - return self.__hash diff --git a/python/ycm/user_options_store.py b/python/ycm/user_options_store.py index 7a4c8328..fdb422a9 100644 --- a/python/ycm/user_options_store.py +++ b/python/ycm/user_options_store.py @@ -19,7 +19,7 @@ import json import os -from ycm.frozendict import frozendict +from frozendict import frozendict _USER_OPTIONS = {} diff --git a/third_party/frozendict b/third_party/frozendict new file mode 160000 index 00000000..2ea45f3f --- /dev/null +++ b/third_party/frozendict @@ -0,0 +1 @@ +Subproject commit 2ea45f3f429c5283f9f24738812f0ee152a8f4c1