forked from cobrateam/splinter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeta.py
More file actions
27 lines (21 loc) · 959 Bytes
/
meta.py
File metadata and controls
27 lines (21 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
class InheritedDocs(type):
def __new__(mcs, class_name, bases, dict):
items_to_patch = [(k, v) for k, v in dict.items()
if not k.startswith('__') and not v.__doc__]
for name, obj in items_to_patch:
doc = None
for base in bases:
if hasattr(base, name):
doc = getattr(base, name).__doc__
if doc:
if isinstance(obj, property) and not obj.fset:
obj.fget.__doc__ = doc
dict[name] = property(fget=obj.fget)
else:
obj.__doc__ = doc
break
return type.__new__(mcs, class_name, bases, dict)