(self, params, **kwargs)
| 2937 | return clipboard_copy_parser |
| 2938 | |
| 2939 | def execute(self, params, **kwargs): |
| 2940 | record_name = kwargs['record'] if 'record' in kwargs else '' |
| 2941 | |
| 2942 | if not record_name: |
| 2943 | self.get_parser().print_help() |
| 2944 | return |
| 2945 | |
| 2946 | user_pattern = None |
| 2947 | if kwargs['username']: |
| 2948 | user_pattern = re.compile(kwargs['username'], re.IGNORECASE) |
| 2949 | |
| 2950 | record_uid = None |
| 2951 | if record_name in params.record_cache: |
| 2952 | record_uid = record_name |
| 2953 | else: |
| 2954 | rs = try_resolve_path(params, record_name) |
| 2955 | if rs is not None: |
| 2956 | folder, record_name = rs |
| 2957 | if folder is not None and record_name is not None: |
| 2958 | folder_uid = folder.uid or '' |
| 2959 | if folder_uid in params.subfolder_record_cache: |
| 2960 | for uid in params.subfolder_record_cache[folder_uid]: |
| 2961 | r = vault.KeeperRecord.load(params, uid) |
| 2962 | if not isinstance(r, (vault.PasswordRecord, vault.TypedRecord)): |
| 2963 | continue |
| 2964 | if r.title.lower() == record_name.lower(): |
| 2965 | if user_pattern: |
| 2966 | login = '' |
| 2967 | if isinstance(r, vault.PasswordRecord): |
| 2968 | login = r.login |
| 2969 | elif isinstance(r, vault.TypedRecord): |
| 2970 | login_field = r.get_typed_field('login') |
| 2971 | if login_field is None: |
| 2972 | login_field = r.get_typed_field('email') |
| 2973 | if login_field: |
| 2974 | login = login_field.get_default_value(str) |
| 2975 | if not login: |
| 2976 | continue |
| 2977 | if not user_pattern.match(login): |
| 2978 | continue |
| 2979 | record_uid = uid |
| 2980 | break |
| 2981 | |
| 2982 | if record_uid is None: |
| 2983 | records = [] # type: List[vault.KeeperRecord] |
| 2984 | for r in vault_extensions.find_records(params, record_name, use_regex=True): |
| 2985 | if isinstance(r, (vault.PasswordRecord, vault.TypedRecord)): |
| 2986 | if user_pattern: |
| 2987 | login = '' |
| 2988 | if isinstance(r, vault.PasswordRecord): |
| 2989 | login = r.login |
| 2990 | elif isinstance(r, vault.TypedRecord): |
| 2991 | login_field = r.get_typed_field('login') |
| 2992 | if login_field is None: |
| 2993 | login_field = r.get_typed_field('email') |
| 2994 | if login_field: |
| 2995 | login = login_field.get_default_value(str) |
| 2996 | if not login: |
no test coverage detected