text
stringlengths
0
601k
type t = KeywordValue . t list
let all_servers config = Utils . options ( List . map ( function ( KeywordValue . Nameserver x ) -> Some x | _ -> None ) config )
let choose_server config = match ( all_servers config ) with | [ ] -> None | x :: _ -> Some x
let parse_file ( ? file " =/ etc / resolv . conf " ) ( ) =
let find_dot_git ( ) = let rec search dir = let dot_git = Filename . concat dir " . git " in if Sys . file_exists dot_git && Sys . is_directory dot_git then Some dot_git else let parent_dir = Filename . dirname dir in if not ( String . equal dir parent_dir ) then search parent_dir else None in search ( Sys . getcwd ( )...
let parse_dot_git ( ) = let dot_git = find_dot_git ( ) in match dot_git with | None -> Error " No . git directory found in this directory , nor in a parent \ directory . " | Some dot_git -> let config_file = Filename . concat dot_git " config " in begin try let chan = open_in config_file in let lexbuf = Lexing . from_c...
let gitlab_project_from_url url = let regex = Str . regexp " ^ git [ @ A - Za - z0 - 9 . ] ( [ -+:\\ A - Za - z0 - 9 ] [ -+/ A - Za - z ] ) ( . -+\\\\\\ git ) \\?$\ \\|\ ^ https [ : A - Za - z0 - 9 . ] ( [ /-+/\\ A - Za - z0 - 9 ] [ -+/ A - Za - z ] ) ( . -+\\\\\\ git ) " \\?$ in if Str . string_match regex url 0 then ...
let gitlab_project_name ? remote config = match remote with | Some remote -> begin try let settings = List . assoc ( " remote " " \ ^ remote ^ " " " ) \ config in let url = List . assoc " url " settings in gitlab_project_from_url url with Not_found -> None end | None -> let remotes = List . filter ( fun ( name , _ ) ->...
let test_apply_decorators context = let resolution = ScratchProject . setup ~ context [ ] |> ScratchProject . build_global_resolution in let create_define ~ decorators ~ parameters ~ return_annotation = { Define . Signature . name = " !& define " ; parameters ; decorators ; return_annotation ; async = false ; generator...
let ( ) = " resolvedCallable " >::: [ " apply_decorators " >:: test_apply_decorators ] |> Test . run
type result_space = Time . Interval ' . t list
let default_result_space : result_space = [ ( default_result_space_start , default_result_space_end_exc ) ]
type t = | Empty | All | Intervals of result_space * Time . Interval ' . t Seq . t | ISO_week_pattern of result_space * Int_set . t * Int_set . t | Pattern of result_space * Pattern . t | Pattern_intervals of { result_space : result_space ; mode : [ ` Whole_inc | ` Whole_exc | ` Fst | ` Snd ] ; bound : Timedesc . Span ...
let rec t_of_ast ( ast : Time_ast . t ) : t = match ast with | Empty -> Empty | All -> All | Intervals s -> Intervals ( default_result_space , s ) | ISO_week_pattern ( years , weeks ) -> ISO_week_pattern ( default_result_space , years , weeks ) | Pattern p -> Pattern ( default_result_space , p ) | Unary_op ( op , t ) -...
let result_space_of_t ( time : t ) : result_space = match time with | All -> default_result_space | Empty -> empty_result_space | Intervals ( s , _ ) -> s | ISO_week_pattern ( s , _ , _ ) -> s | Pattern ( s , _ ) -> s | Pattern_intervals { result_space ; _ } -> result_space | Unary_op ( s , _ , _ ) -> s | Inter_seq ( s...
let deduce_child_result_space_bound_from_parent ( ~ parent : t ) : result_space = let open Timedesc . Span in let space = result_space_of_t parent in match parent with | All | Empty | Intervals _ | ISO_week_pattern _ | Pattern _ | Pattern_intervals _ -> failwith " Unexpected case " | Unary_op ( _ , op , _ ) -> ( match ...
let set_result_space space ( t : t ) : t = match t with | All -> All | Empty -> Empty | Intervals ( _ , x ) -> Intervals ( space , x ) | ISO_week_pattern ( _ , x , y ) -> ISO_week_pattern ( space , x , y ) | Pattern ( _ , x ) -> Pattern ( space , x ) | Unary_op ( _ , op , x ) -> Unary_op ( space , op , x ) | Inter_seq ...
let result_space_of_year_range tz year_range = let aux_start start = if start = Timedesc . ( year min_val ) then Timedesc . Timestamp . min_val else Timedesc . make_exn ~ tz ~ year : start ~ month : 1 ~ day : 1 ~ hour : 0 ~ minute : 0 ~ second : 0 ( ) |> Timedesc . to_timestamp |> Timedesc . min_of_local_result in let ...
let result_space_of_year tz year = result_space_of_year_range tz ( ` Range_inc ( year , year ) )
let restrict_result_space ( ~ bound : result_space ) t = let open Time in let cur = result_space_of_t t in let new_result_space = Intervals . Inter . inter ~ skip_check : true ( CCList . to_seq cur ) ( CCList . to_seq bound ) |> CCList . of_seq in set_result_space new_result_space t
let overapproximate_result_space_bottom_up default_tz ( t : t ) : t = let open Time in let rec aux ( tz : Timedesc . Time_zone . t ) ( t : t ) : t = match t with | All -> All | Empty -> Empty | Intervals ( _ , s ) -> ( match s ( ) with | Seq . Nil -> t | Seq . Cons ( ( start , _ ) , _ ) -> Intervals ( [ ( start , defau...
let restrict_result_space_top_down ( t : t ) : t = let rec aux bound ( t : t ) : t = let t = restrict_result_space ~ bound t in match t with | All | Empty | Intervals _ | ISO_week_pattern _ | Pattern _ | Pattern_intervals _ -> t | Unary_op ( cur , op , t ' ) -> Unary_op ( cur , op , aux ( deduce_child_result_space_boun...
let optimize_search_space default_tz t = t |> overapproximate_result_space_bottom_up default_tz |> restrict_result_space_top_down
type inc_or_exc = | Inc | Exc
let do_chunk_at_year_boundary tz ( s : Time . Interval ' . t Seq . t ) = let rec aux s = match s ( ) with | Seq . Nil -> Seq . empty | Seq . Cons ( ( t1 , t2 ) , rest ) -> let dt1 = CCOption . get_exn_or " Expected successful date time construction " @@ Timedesc . of_timestamp ~ tz_of_date_time : tz t1 in let dt2 = t2 ...
let do_chunk_at_month_boundary tz ( s : Time . Interval ' . t Seq . t ) = let rec aux s = match s ( ) with | Seq . Nil -> Seq . empty | Seq . Cons ( ( t1 , t2 ) , rest ) -> let dt1 = CCOption . get_exn_or " Expected successful date time construction " @@ Timedesc . of_timestamp ~ tz_of_date_time : tz t1 in let dt1_year...
let dynamic_search_space_adjustment_trigger_size = Timedesc . Span . For_human . ( make_exn ~ days : 30 ( ) )
let inter_slice_size = Timedesc . Span . For_human . ( make_exn ~ days : 10 ( ) )
let slice_result_space ~ start ( t : t ) : t = let current = result_space_of_t t |> CCList . to_seq in let space = Time . Intervals . Slice . slice ~ skip_check : true ~ start current |> CCList . of_seq in set_result_space space t |> restrict_result_space_top_down
let slice_result_space_multi ~ start ( l : t list ) : t list = List . map ( slice_result_space ~ start ) l
let slice_result_space_multi_seq ~ start ( s : t Seq . t ) : t Seq . t = Seq . map ( slice_result_space ~ start ) s
let normalize s = s |> Time . Intervals . normalize ~ skip_filter_empty : false ~ skip_filter_invalid : true ~ skip_sort : true |> Time . slice_valid_interval
let aux_iso_week_pattern search_using_tz space years weeks = match space with | [ ] -> Seq . empty | _ -> let space_start = fst @@ List . hd space in let space_end = Timedesc . Timestamp . pred @@ snd @@ List . hd @@ List . rev space in let start_year = max 1 ( Timedesc . year @@ Timedesc . of_timestamp_exn ~ tz_of_dat...
let aux_pattern search_using_tz space pat = let open Time in let space = CCList . to_seq space in Timedesc . Time_zone . Raw . to_transition_seq search_using_tz |> Seq . flat_map ( fun ( ( x , y ) , entry ) -> let x = Timedesc . Span . make ~ s : x ( ) in let y = Timedesc . Span . make ~ s : y ( ) in let space = Interv...
let one_s = Timedesc . Span . make ~ s : 1L ( )
let aux_points search_using_tz space ( p : Points . t ) : timestamp Seq . t = let search_using_tz = match p . tz_info with | None -> search_using_tz | Some tz_info -> Timedesc . Time_zone_info . tz tz_info in aux_pattern search_using_tz space ( Points . to_pattern p ) |> Seq . filter_map ( fun ( x , y ) -> assert ( Tim...
let rec aux search_using_tz time = let open Time in ( match result_space_of_t time with | [ ] -> Seq . empty | _ -> ( match time with | Empty -> Seq . empty | All -> CCList . to_seq default_result_space | Intervals ( _ , s ) -> s | ISO_week_pattern ( space , years , weeks ) -> aux_iso_week_pattern search_using_tz space...
let resolve ' ~ search_using_tz ( time : t ) : ( Time . Interval ' . t Seq . t , string ) result = let open Time in try Ok ( time |> optimize_search_space search_using_tz |> aux search_using_tz ) with | Interval_is_invalid -> Error " Invalid interval " | Intervals_are_not_sorted -> Error " Intervals are not sorted "
let resolve ( ? search_using_tz = Timedesc . Time_zone . utc ) ( time : Time_ast . t ) : ( Time . Interval ' . t Seq . t , string ) result = resolve ' ~ search_using_tz ( t_of_ast time )
let debug = ref false
let debug_print = ref Printf . eprintf
let ( ) = try ignore ( Sys . getenv " CONDUIT_DEBUG " ) ; debug := true with Not_found -> ( )
let return_endp name svc uri endp = if ! debug then ! debug_print " Resolver % s : % s % s -> % s \ n " %! name ( Uri . to_string uri ) ( Sexplib . Sexp . to_string_hum ( Resolver . sexp_of_service svc ) ) ( Sexplib . Sexp . to_string_hum ( Conduit . sexp_of_endp endp ) ) ; Lwt . return endp
let is_tls_service = function | " https " | " imaps " -> true | _ -> false
let system_service name = Lwt . catch ( fun ( ) -> Lwt_unix . getservbyname name " tcp " >>= fun s -> let tls = is_tls_service name in let svc = { Resolver . name ; port = s . Lwt_unix . s_port ; tls } in Lwt . return ( Some svc ) ) ( function Not_found -> Lwt . return_none | e -> Lwt . fail e )
let static_service name = match Uri_services . tcp_port_of_service name with | [ ] -> Lwt . return_none | port :: _ -> let tls = is_tls_service name in let svc = { Resolver . name ; port ; tls } in Lwt . return ( Some svc )
let get_host uri = match Uri . host uri with | None -> " localhost " | Some host -> ( match Ipaddr . of_string host with | Ok ip -> Ipaddr . to_string ip | Error _ -> host )
let get_port service uri = match Uri . port uri with None -> service . Resolver . port | Some port -> port
let system_resolver service uri = let open Lwt_unix in let host = get_host uri in let port = get_port service uri in getaddrinfo host ( string_of_int port ) [ AI_SOCKTYPE SOCK_STREAM ] >>= fun addrinfos -> let v4 , rest = List . partition ( fun i -> i . ai_family = PF_INET ) addrinfos in match List . rev_append v4 rest...
let static_resolver hosts service uri = try return_endp " static " service uri ( Hashtbl . find hosts ( get_host uri ) ) with Not_found -> return_endp " static " service uri ( ` Unknown " name resolution failed " )
let system = let service = system_service in let rewrites = [ ( " " , system_resolver ) ] in Resolver_lwt . init ~ service ~ rewrites ( )
let static hosts = let service = static_service in let rewrites = [ ( " " , static_resolver hosts ) ] in Resolver_lwt . init ~ service ~ rewrites ( )
module type S = sig include Resolver_lwt . S val static : ( string , port : int -> Conduit . endp ) Hashtbl . t -> t val localhost : t end
module Make ( R : Mirage_random . S ) ( T : Mirage_time . S ) ( C : Mirage_clock . MCLOCK ) ( P : Mirage_clock . PCLOCK ) ( S : Tcpip . Stack . V4V6 ) = struct include Resolver_lwt let is_tls_service = function | " https " | " imaps " -> true | _ -> false let get_host uri = match Uri . host uri with | None -> " localho...
let in_source_dir p = if Pathname . is_implicit p then Pathname . pwd / p else invalid_arg ( Printf . sprintf " in_source_dir : % S " p )
let in_build_dir p = if Pathname . is_relative p then p else invalid_arg ( Printf . sprintf " in_build_dir : % S " p )
let clean_up_links entry = if not ! Options . make_links then entry else Slurp . filter begin fun path name _ -> let pathname = in_source_dir ( path / name ) in if Pathname . link_to_dir pathname ! Options . build_dir then let z = Pathname . readlink pathname in ( if not ( Sys . file_exists z ) then Shell . rm pathname...
let clean_up_link_to_build ( ) = Options . entry := Some ( clean_up_links ( the ! Options . entry ) )
let source_dir_path_set_without_links_to_build = lazy begin clean_up_link_to_build ( ) ; Slurp . fold ( fun path name _ -> StringSet . add ( path / name ) ) ( the ! Options . entry ) StringSet . empty end
let clean_links ( ) = if !* My_unix . is_degraded then ( ) else ignore ( clean_up_link_to_build ( ) )
let exists_in_source_dir p = if !* My_unix . is_degraded then sys_file_exists ( in_source_dir p ) else StringSet . mem p !* source_dir_path_set_without_links_to_build
let clean p = Shell . rm_f p
module Cache = struct let clean ( ) = Shell . chdir Pathname . pwd ; Shell . rm_rf ! Options . build_dir type knowledge = | Yes | No | Unknown type suspension = ( Command . t * ( unit -> unit ) ) type build_status = | Bbuilt | Bcannot_be_built | Bnot_built_yet | Bsuspension of suspension type cache_entry = { mutable bu...
let digest p = let f = Pathname . to_string ( in_build_dir p ) in let buf = Buffer . create 1024 in Buffer . add_string buf f ; ( if sys_file_exists f then Buffer . add_string buf ( Digest . file f ) ) ; Digest . string ( Buffer . contents buf )
let exists_in_build_dir p = Pathname . exists ( in_build_dir p )
let import x = Pathname . normalize x
module MetaPath : sig type t val mk : ( bool * string ) -> t open Glob_ast | ` Var ( var_name , globber ) -> V ( var_name , globber ) | ` Word s -> A s end ( Lexers . path_scheme pattern_allowed ( Lexing . from_string s ) ) let mk = memo mk begin match String . contains_string s ( pos + delta ) s2 with | Some ( pos ' )...
type resource_pattern = ( Pathname . t * MetaPath . t )
let print_pattern f ( x , _ ) = Pathname . print f x
let import_pattern x = x , MetaPath . mk ( true , x )
let matchit ( _ , p ) x = MetaPath . matchit p x
let subst env s = MetaPath . subst env ( MetaPath . mk ( false , s ) )
let subst_any env s = MetaPath . subst env ( MetaPath . mk ( true , s ) )
let subst_pattern env ( _ , p ) = MetaPath . subst env p
let cols = new GTree . column_list
let col_name = cols # add Gobject . Data . string
let col_pixbuf = cols # add ( Gobject . Data . gobject_by_name " GdkPixbuf " )
let col_icofile = cols # add Gobject . Data . string let saved = new saved ( ) in let icon_changed = new icon_changed ( ) in let table = GPack . table ~ row_spacings : 8 ~ col_spacings : 8 ? packing ( ) in let i = ref 0 in let _ = GMisc . label ~ text " : Title " : ~ xalign : 0 . 0 ~ packing ( : table # attach ~ expand...
let window ~ project ~ target ( ) = let window = GWindow . window ~ title " : Icons and Assembly Information " ~ modal : true ( ) ~ icon : Icons . oe ~ position ` : CENTER ~ show : false in Gmisclib . Util . esc_destroy_window window ; let vbox = GPack . vbox ~ spacing : 8 ~ border_width : 8 ~ packing : window # add ( ...
type error = [ ` Malformed_response of string | ` Invalid_response_body_length of Response . t | ` Protocol_error of Error_code . t * string | ` Exn of exn ]
type error_handler = error -> unit
type response_handler = Response . t -> Body . Reader . t -> unit
type response_info = { response : Response . t ; response_body : Body . Reader . t ; mutable response_body_bytes : int64 ; mutable trailers_parser : Stream . partial_headers option }
type trailers_handler = Headers . t -> unit
type active_request = { request : Request . t ; request_body : Body . Writer . t ; response_handler : response_handler ; trailers_handler : trailers_handler }
type active_state = ( response_info , response_info remote_state ) remote_state Stream . active_state
type state = ( active_state , active_request , active_request Stream . remote_state ) Stream . state
type t = ( state , [ ` Ok | error ] , error_handler ) error_handler Stream . stream
let create_active_response response response_body = ActiveMessage { response ; response_body ; response_body_bytes = Int64 . zero ; trailers_parser = None }
let response_body_exn t = match t . state with | Idle | Reserved _ -> failwith " h2 . Respd . response_exn : response has not arrived " | Active ( ( Open ( ActiveMessage { response_body ; _ } ) | HalfClosed ( ActiveMessage { response_body ; _ } ) ) , _ ) -> response_body | Active ( ( Open _ | HalfClosed _ ) _ , _ ) _ -...
let close_stream t = match t . state with | Active ( HalfClosed _ , _ ) _ -> finish_stream t Finished | Active ( Open _ , _ ) _ -> ( ) | _ -> ( )
let _report_error t ? response_body error error_code = match fst t . error_code with | ` Ok -> ( match response_body with | Some response_body -> Body . Reader . close response_body ; Body . Reader . execute_read response_body | None -> ( ) ) ; t . error_code <- ( error :> [ ` Ok | error ] ) , Some error_code ; t . err...
let report_error t error error_code = match t . state with | Active ( ( Open ( ActiveMessage { response_body ; _ } ) | HalfClosed ( ActiveMessage { response_body ; _ } ) ) , s ) -> Body . Writer . close s . request_body ; if _report_error t ~ response_body error error_code then reset_stream t error_code | Reserved ( Ac...
let error_code t = match fst t . error_code with # error as error -> Some error | ` Ok -> None
let requires_output t = match t . state with | Idle -> true | Reserved _ -> false | Active ( Open _ , _ ) _ -> true | Active ( HalfClosed _ , _ ) _ -> false | Closed _ -> false
let flush_request_body t ~ max_bytes = match t . state with | Active ( Open active_state , ( { request_body ; _ } as s ) s ) s -> if Body . Writer . has_pending_output request_body && max_bytes > 0 then Body . Writer . transfer_to_writer request_body t . writer ~ max_frame_size : t . max_frame_size ~ max_bytes t . id e...
let deliver_trailer_headers t headers = match t . state with | Active ( ( Open ( ActiveMessage _ ) _ | HalfClosed ( ActiveMessage _ ) _ ) _ , { trailers_handler ; _ } ) -> trailers_handler headers | _ -> assert false
let flush_response_body t = match t . state with | Active ( ( Open ( ActiveMessage { response_body ; _ } ) | HalfClosed ( ActiveMessage { response_body ; _ } ) ) , _ ) -> if Body . Reader . has_pending_output response_body then ( try Body . Reader . execute_read response_body with | exn -> report_error t ( ` Exn exn ) ...
type error = [ ` Bad_payload | ` Incomplete_payload | P . error ]
type ' a t = More of ' a | Done of ' a