示例#1
0
 def cons(
     ident: IdentSpec = None,
     state: ViewState = None,
     geometry: ViewGeometry = None,
     open: bool = False,
     cwd: Path = None,
     pin: bool = False,
 ) -> 'SimplePane':
     return SimplePane(
         ensure_ident_or_generate(ident),
         state or ViewState.cons(),
         geometry or ViewGeometry.cons(),
         Boolean(open),
         Maybe.optional(cwd),
         Boolean(pin),
     )
示例#2
0
 def cons(
     ident: IdentSpec = None,
     state: ViewState = None,
     geometry: ViewGeometry = None,
     vertical: bool = True,
 ) -> 'SimpleLayout':
     return SimpleLayout(
         ensure_ident_or_generate(ident),
         state or ViewState.cons(),
         geometry or ViewGeometry.cons(),
         Boolean(vertical),
     )
示例#3
0
 def search(monitor) -> None:
     r = monitor['release']
     date = Try(datetime.strptime, r['airdate'], '%Y-%m-%d') | None
     release = Release(name=r['series'], season=r['season'], episode=r['episode'], search_name=r['search_name'],
                       airdate=date)
     query = cmd.rest.filter_not(_.empty) / _.join_tokens | release.search_query_no_res
     query1 = release.search_query_date if query == 'date' else query
     self.log.info(f'Searching torrent for "{release}" with query "{query1}"...')
     dl = TorrentDownloader([query1])
     res = Boolean(dl._search()).m(dl.search_results) / Lists.wrap // _.head
     return (
         res /
         (lambda l: cmd.put(data=(lambda i: Just(dict(url=l))), path=Just('link'))) |
         IO.failed('no search results')
     )
示例#4
0
 def decode(self, tpe: Type[Boolean],
            data: Json) -> Either[JsonError, Boolean]:
     return data.scalar.e(f'invalid type for `Boolean`: {data}',
                          Boolean(data.data))
示例#5
0
文件: debug.py 项目: yuhangwang/amino
 def try_sub(new, rest):
     is_lambda = Boolean(arg is AttrLambdaInst
                         or isinstance(arg, AnonAttr))
     return is_lambda.m(lambda: (transform(new), rest))
示例#6
0
 def null(self) -> Boolean:
     return Boolean.isinstance(self, JsonNull)
示例#7
0
 def absent(self) -> Boolean:
     return Boolean.isinstance(self, JsonAbsent)
示例#8
0
 def object(self) -> Boolean:
     return Boolean.isinstance(self, JsonObject)
示例#9
0
 def array(self) -> Boolean:
     return Boolean.isinstance(self, JsonArray)
示例#10
0
 def scalar(self) -> Boolean:
     return Boolean.isinstance(self, JsonScalar)
示例#11
0
def path_lens_pred(a: A, sub: Callable[[A], List[A]], lsub,
                   f: Callable[[A], bool]) -> Maybe[BoundLens]:
    g = lambda a: Boolean(f(lsub(a))).maybe(lsub(lens))
    return path_lens(a, sub, g)
示例#12
0
def function_bindings_relay(f: Callable) -> Boolean:
    target = f.__do_original if hasattr(f, '__do') else f
    anno = inspect.getfullargspec(target).annotations
    return Boolean(anno.get('bindings', None) is Bindings)
示例#13
0
def layout_panes(node: LayoutNode) -> List[PaneNode]:
    return node.sub.filter(Boolean.is_a(PaneNode))