@@ -245,7 +245,7 @@ def norm(p):
245245def to_native (path ):
246246 """
247247 Return a path using the current OS path separator given a path that may
248- contain posix or windows separators, converting "/" to "\\ " on windows
248+ contain posix or windows separators, converting "/" to "\\ " on windows
249249 and "\\ " to "/" on posix OSes.
250250 """
251251 path = path .replace (ntpath .sep , os .path .sep )
@@ -532,7 +532,7 @@ def have_network_connection():
532532 else :
533533 import http .client as httplib # NOQA
534534
535- http_connection = httplib .HTTPConnection ('dejacode.org' , timeout = 10 )
535+ http_connection = httplib .HTTPConnection ('dejacode.org' , timeout = 10 ) # NOQA
536536 try :
537537 http_connection .connect ()
538538 except socket .error :
@@ -605,7 +605,7 @@ def copy_license_notice_files(fields, base_dir, reference_dir, afp):
605605 where reference license an notice files are stored and the `afp`
606606 about_file_path value, this function will copy to the base_dir the
607607 license_file or notice_file if found in the reference_dir
608-
608+
609609 """
610610 lic_name = ''
611611 for key , value in fields :
@@ -769,66 +769,3 @@ def unique(sequence):
769769 if item not in deduped :
770770 deduped .append (item )
771771 return deduped
772-
773-
774- # FIXME: remove and replace by saneyaml
775- from collections import Hashable
776-
777- from yaml .reader import Reader
778- from yaml .scanner import Scanner
779- from yaml .parser import Parser
780- from yaml .composer import Composer
781- from yaml .constructor import Constructor , ConstructorError
782- from yaml .resolver import Resolver
783- from yaml .nodes import MappingNode
784-
785- # FIXME: add docstring
786- class NoDuplicateConstructor (Constructor ):
787- def construct_mapping (self , node , deep = False ):
788- if not isinstance (node , MappingNode ):
789- raise ConstructorError (
790- None , None ,
791- "expected a mapping node, but found %s" % node .id ,
792- node .start_mark )
793- mapping = {}
794- for key_node , value_node in node .value :
795- # keys can be list -> deep
796- key = self .construct_object (key_node , deep = True )
797- # lists are not hashable, but tuples are
798- if not isinstance (key , Hashable ):
799- if isinstance (key , list ):
800- key = tuple (key )
801-
802- if sys .version_info .major == 2 :
803- try :
804- hash (key )
805- except TypeError as exc :
806- raise ConstructorError (
807- "while constructing a mapping" , node .start_mark ,
808- "found unacceptable key (%s)" %
809- exc , key_node .start_mark )
810- else :
811- if not isinstance (key , Hashable ):
812- raise ConstructorError (
813- "while constructing a mapping" , node .start_mark ,
814- "found unhashable key" , key_node .start_mark )
815-
816- value = self .construct_object (value_node , deep = deep )
817-
818- # Actually do the check.
819- if key in mapping :
820- raise KeyError ("Got duplicate key: {!r}" .format (key ))
821-
822- mapping [key ] = value
823- return mapping
824-
825-
826- # FIXME: add docstring
827- class NoDuplicateLoader (Reader , Scanner , Parser , Composer , NoDuplicateConstructor , Resolver ):
828- def __init__ (self , stream ):
829- Reader .__init__ (self , stream )
830- Scanner .__init__ (self )
831- Parser .__init__ (self )
832- Composer .__init__ (self )
833- NoDuplicateConstructor .__init__ (self )
834- Resolver .__init__ (self )
0 commit comments